t = int(input()) for i in range(t): s = input() while len(s) != 1: tmp = "" for i in range(len(s) -1): a = int(s[i]) + int(s[i+1]) b = a // 10 + a % 10 tmp += str(b) s = tmp print(s)