Pagini recente » Cod sursa (job #629718) | Cod sursa (job #294440) | Cod sursa (job #615768) | Cod sursa (job #199095) | Cod sursa (job #2002123)
var a,b:qword;
i,j,t,x,y,m,n:longint;
s:string;
begin
assign(input,'cifra.in');
reset(input);
assign(output,'cifra.out');
rewrite(output);
readln(t);
for x:=1 to t do
begin
readln(s);
if length(s)>2 then s:=s[length(s)-1]+s[length(s)];
val(s,n,m);
a:=0;
for i:=1 to n do
begin
b:=1;
for j:=1 to i do
begin b:=b*i; b:=b mod 1000; end;
a:=a+b;
a:=a mod 10;
end;
writeln(a mod 10);
end;
close(input);
{for n:=1 to 150 do
begin
a:=0;}
{ for i:=1 to n do
begin
b:=1;
for j:=1 to i do
begin b:=b*i; b:=b mod 1000; end;
a:=a+b;
a:=a mod 10;
end;
writeln(a mod 10);
end;}
close(output);
end.