Pagini recente » Cod sursa (job #1550230) | Cod sursa (job #1847347) | Cod sursa (job #1833176) | Cod sursa (job #2622023) | Cod sursa (job #1169442)
var t,i:byte;
a,b,c,x,y,z:word;
n:longword;
f,g:text;
function fun(s:longword):longword;
begin
if s=0 then fun:=x
else if s=1 then fun:=y
else if s=2 then fun:=z
else fun:=a*fun(s-1)+b*fun(s-2)+c*fun(s-3);
end;
begin
assign(f,'iepuri.in'); assign(g,'iepuri.out'); reset(f); rewrite(g);
readln(f,t);
for i:=1 to t do
begin
readln(f,x,y,z,a,b,c,n);
writeln(g,fun(n) mod 666013);
end;
close(f);
close(g);
end.