#include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef unsigned u; typedef vector vi; typedef pair pii; #define F first; #define S second; #define PB push_back; #define MP make_pair; #define MOD 1000000007 ull modpow(int k, int n, ull acc){ //cout << acc << endl; if(n != k){ return modpow(k, n + 1, acc * 2) % MOD; } return acc/2 * k % MOD; } bool EQ(double a, double b) { return (fabs(a-b) / (a+b) < DBL_EPSILON); } int main( ) { ios_base::sync_with_stdio(0); cin.tie(0); // code int a, b, c, k; cin >> a >> b >> k >> c; if(a == b && a == c){ cout << k << endl; return 0; } else if(a != c && b != c){ cout << 0 << endl; return 0; } cout << modpow(k, 0, 1) << endl; return 0; }