Pagini recente » Cod sursa (job #2748807) | Cod sursa (job #60983) | Cod sursa (job #611026) | Cod sursa (job #739517) | Cod sursa (job #393410)
Cod sursa(job #393410)
var f,g:text;
t,x,y,z,a,b,c,n,s:int64;
i,j:longint;
begin
assign(f,'iepuri.in');
reset(f);
assign(g,'iepuri.out');
rewrite(g);
readln(f,t);
for i:=1 to t do begin
read(f,x);read(f,y);read(f,z);read(f,a);read(f,b);read(f,c);readln(f,n);
s:=0;
for j:=4 to n do begin
s:=(a*z)+(b*y)+(c*x);
x:=y;
y:=z;
z:=s;
end;
writeln(g,s mod 666013);
end;
close(f);
close(g);
end.