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
from sys import stdin
a = '0123456789'
b = [6,2,5,5,4,5,6,3,7,6]
di = {}
for i in xrange(10):
	di[a[i]] = b[i]
t = int(stdin.readline())
for _ in xrange(t):
	a = stdin.readline().strip()
	ans = 0
	for i in a:
		ans += di[i]
	print ans