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
t=int(input())
while t>0:
    s=raw_input()
    n=0
    for i in range(len(s)):
        if s[i]=='0':
            n=n+6
        elif s[i]=='1':
            n=n+2
        elif s[i]=='2':
            n=n+5
        elif s[i]=='3':
            n=n+5
        elif s[i]=='4':
            n=n+4
        elif s[i]=='5':
            n=n+5
        elif s[i]=='6':
            n=n+6
        elif s[i]=='7':
            n=n+3
        elif s[i]=='8':
            n=n+7
        else:
            n=n+6
    print(n)
    t=t-1