Pagini recente » Cod sursa (job #269095) | Cod sursa (job #153334) | Cod sursa (job #3213518) | Cod sursa (job #3173016) | Cod sursa (job #735868)
Cod sursa(job #735868)
#include<fstream>
using namespace std;
ifstream fin("matrice5.in");
ofstream fout("matrice5.out");
int f(int n, int m)
{
if(m==0)return 1;
else if(m%2==0) return f(n*n%10007, m>>1);
else return n*f(n*n%10007, m>>1)%10007;
}
int main(){
int n, m, p, k, t;
fin>>t;
while(t)
{
fin>>n>>m>>p>>k;
fout<<f(k,(n-1)*(m-1))*f(p,n*m)<<"\n";
t--;
}
fin.close();
fout.close();
return 0;
}