Problem: Solve the mystery

HINT : Digital Display
Input :
First line has an integer T.
Next T lines has an integer N in each line. It is guaranteed that N never starts with 0 unless value is equal to zero.

Output :
Print the output for each test case in new line.

Constraints :
1 ≤ T ≤ 1000
0 ≤ |N| ≤ 1000
|N| is number of digits.

Problem Setter : Vinay Kumar

SAMPLE INPUT
8
1234567
123456
1234
193
12
11
1
0

SAMPLE OUTPUT
30
27
16
13
7
4
2
6

Solution (in PYTHON):

Solution:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
n=int(raw_input())
dict={0:6,1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
c=0
for i in range(n):
	sum=0
	a=int(raw_input())
	if(a==0):
		print(6)
	else:
		while(a):
			c=a%10;
			a=a/10
			sum=sum+dict.get(c)
		print(sum)