#include #include using namespace std; int power(short a, short b) { int result = 1; while (b > 0) { b--; result *= a; result %= 1000000007; } return result; } int main() { short a, b, k, c; int result; cin >> a >> b >> k >> c; if (c != a && c != b) { result = 0; } else if (a == b) { result = k; } else { result = (power(2, k - 1) * k) % 1000000007; } cout << result << endl; return 0; }