Kancha wants to participate in a new event of Technobyte. Event says that you have to write a number in seven segment display using matchsticks. Please refer to the diagram below for how many sticks are used for each digit !!

Now, event coordinator gave kancha a long string. your task is to tell how many matchsticks will be used in writing that number as in the seven segment display !!

Input:
First line of input contains an integer t, then t lines follow each containing a number less than 10^5 digits !

Output:
Print one line containing the integer denoting the number of matchsticks used.

Constraints:
0<t ≤10
0 ≤ Input number ≤ 10^(10^5)

SAMPLE INPUT
1
13579

SAMPLE OUTPUT
21

Explanation

1 takes 2 sticks
3 takes 5 sticks
5 takes 5 sticks
7 takes 3 sticks
9 takes 6 sticks
Total = 21 sticks
for t in range(input()):
 s=raw_input()
 i=0
 l=len(s)
 count=0
 while i<l:
  ch=s[i]
  if ch=='0':
   count=count+6
  elif ch=='1':
   count=count+2
  elif ch=='2':
   count=count+5
  elif ch=='3':
   count=count+5
  elif ch=='4':
   count=count+4
  elif ch=='5':
   count=count+5
  elif ch=='6':
   count=count+6
  elif ch=='7':
   count=count+3
  elif ch=='8':
   count=count+7
  else:
   count=count+6
  i=i+1
 print count