Pagini recente » Cod sursa (job #837423) | Cod sursa (job #2963780) | Cod sursa (job #2183261) | Cod sursa (job #577080) | Cod sursa (job #393411)
Cod sursa(job #393411)
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:=3 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.