a = [0,5,8,8,2,3,5,2,9,4,1,1,7,6,4,7]
while True:
try:
n = int(input())
for i in range(n):
b = int(input())
count = 0
for j in range(b):
count += a[j]
print(a[b-1],count)
except:
break
try 拆掉,能看到錯誤訊息。