#include using namespace std; int power(int a){ if(a==0) return 1; int temp=1; for(int i=1;i> a >> b >> k >> c; if(c!=a && c!=b){ cout << vysledok << endl; return 0; } if(a==b){ vysledok=k; } else{ vysledok=power(k)*k; } cout << vysledok%1000000007 << endl; return 0; }