Cod sursa(job #524465)
var t,n,s,c,i :longint;
f,g:text;
function uc(n:longint):byte;
var c,d:byte;
begin
c:=n mod 10;
d:=n mod 100;
if c=0 then uc:=0
else if c=1 then uc:=1;
if c=2 then if d mod 4 =0 then uc:=6
else if d mod 4 =1 then uc:=2
else if d mod 4 =2 then uc:=4
else if d mod 4 =3 then uc:=8;
if c=3 then if d mod 4 =0 then uc:=1
else if d mod 4 =1 then uc:=3
else if d mod 4 =2 then uc:=9
else if d mod 4 =3 then uc:=7;
if c=4 then if d mod 2=0 then uc:=6 else uc:=4;
if c=5 then uc:=5;
if c=6 then uc:=6;
if c=7 then if d mod 4 =0 then uc:=1
else if d mod 4 =1 then uc:=7
else if d mod 4 =2 then uc:=9
else if d mod 4 =3 then uc:=3;
if c=8 then if d mod 4 =0 then uc:=6
else if d mod 4 =1 then uc:=8
else if d mod 4 =2 then uc:=4
else if d mod 4 =3 then uc:=2;
if c=9 then if d mod 2=0 then uc:=1 else uc:=9;
end;
begin
assign(f,'cifra.in');reset(f);
assign(g,'cifra.out');rewrite(g);
readln(f,t); s:=0;
for i:=1 to t do begin
readln(f,n);
s:=s+uc(n);
c:=s mod 10;
writeln(g,c);
end;
close(f);close(g);
end.