for _ in[0]*int(input()): s=input() while len(s)!=1: s2="" for i,j in zip(s[:],s[1:]):t=int(i)+int(j);s2+=str(t%10+t//10) s=s2 print(s)