Pagini recente » Cod sursa (job #475259) | Cod sursa (job #835429) | Cod sursa (job #601685) | Cod sursa (job #835447) | Cod sursa (job #2129884)
#include <iostream>
#include <fstream>
#define MOD 10007
using namespace std;
ifstream in("matrice5.in");
ofstream out("matrice5.out");
int nr,n,m,p,i,T,k;
int expo(int L ,int exp)
{
int P = 1;
while(exp!=0)
{
if(exp%2==1)
P=(P*L)%MOD;
L=(L*L)%MOD;
exp/=2;
}
return P;
}
int main()
{
in>>T;
for(i=1;i<=T;i++){
in>>n>>m>>p>>k;
out<<(((expo(p%MOD,(n*m)%MOD))%MOD)*(expo(k,((n-1)*(m-1)%MOD)))%MOD)%MOD<<"\n";
}
return 0;
}