#include #include #include using namespace std; int fac(int k) { int res = k; for(int i = 0; i < k; i++) { res *= (k - 1); k--; } return res; } int main() { int a, b, c, k; long long int result = 0; cin >> a >> b >> k >> c; if ( c != a && c != b ) { cout << 0 << endl; return 0; } if ( a == b ) { cout << k << endl; return 0; } long long tmpres = 0; for (int i = 0; i < k; i++) { tmpres += fac(k); } tmpres /= 2; //cout << tmpres % 1000000007 << endl; result = tmpres + k; /*if ( k != 1 ) result += k * 2; else result += 1; long long int tmp_result; for (int i = 2; i < k; i++) { tmp_result = 1; for ( int braces = 0 ; braces < i ; braces++ ) tmp_result *= k - braces; tmp_result = ( tmp_result / 2 ) * i; result += tmp_result; //cout << tmp_result << ", " << result << endl; } */ cout << result % 1000000007 << endl; return 0; }