Pagini recente » Cod sursa (job #2903121) | Cod sursa (job #433951) | Cod sursa (job #215307) | Cod sursa (job #1600791) | Cod sursa (job #2637702)
#include <fstream>
#define MOD 666013
using namespace std;
ifstream in("iepuri.in");
ofstream out("iepuri.out");
int w, x, y, z, a, b, c, s, n;
int main() {
in >> w;
for (int q = 1; q <= w; q++) {
in >> x >> y >> z >> a >> b >> c >> n;
for (int i = 3; i <= n; i++) {
s = (1LL * a * z + 1LL*b * y + 1LL * c * x)%MOD;
x = y, y = z, z = s;
}
out << s << '\n';
s = 0;
}
return 0;
}