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