#include #define LL long long using namespace std; int main() { LL A, B, K, C; cin >> A >> B >> K >> C; if (C != A && C != B) { cout << 0 << endl; return 0; } if (K == 0) { cout << 0 << endl; return 0; } else if (K == 1) { cout << 1 << endl; return 0; } LL out = 1; for (LL i = 0; i < K - 1; ++i) { out *= 2; out %= 1000000007; } cout << (out * K) % 1000000007 << endl; return 0; }