Pagini recente » Cod sursa (job #592105) | Cod sursa (job #599140) | Cod sursa (job #3170267) | Cod sursa (job #2772798) | Cod sursa (job #46274)
Cod sursa(job #46274)
var t:0..100;
f,g:text;
x,y,z,a,b,c,n,i,p,j:longint;
begin
assign(f,'iepuri.in');
assign(g,'iepuri.out');
rewrite(g);
reset(f);
readln(f,t);
for i:=1 to t do
begin
readln(f,x,y,z,a,b,c,n);
if n=3 then writeln(g,(x*a+y*b+z*c)mod 666013)
else
begin
for j:=3 to n do
begin
p:=z*a+y*b+c*x;
x:=y;
y:=z;
z:=p;
end;
writeln(g,z mod 666013);
end;
end;
close(f);
close(g);
end.