Pagini recente » Cod sursa (job #223534) | Cod sursa (job #2109993) | Cod sursa (job #2674815) | Cod sursa (job #1298872) | Cod sursa (job #2863329)
#include <bits/stdc++.h>
#define uint unsigned int
using namespace std;
ifstream fin ("iepuri.in");
ofstream fout ("iepuri.out");
const int MOD = 666013;
void test_case(){
int x, y, z;
int c, b, a;
int t, n;
fin>>x>>y>>z>>a>>b>>c>>n;
for(int i=3; i<=n; i++){
t = ((long long)x * c + (long long)y * b + (long long)z * a) % MOD;
x = y;
y = z;
z = t;
}
fout<<z<<"\n";
return;
}
signed main (){
ios_base::sync_with_stdio(false);
fin.tie(nullptr);
fout.tie(nullptr);
int teste;
fin>>teste;
while(teste--)
test_case();
return 0;
}