st = [input() for i in range(int(input()))] for s in st: while len(s)!=1: s2="" s1 = [] for i in range(len(s)-1): t=int(s[i])+int(s[i+1]) t=t%10+t//10 s1.append(str(t)) #s2+=str(t) s="".join(s1) print(s)