What do kids do when they go dine at a Chinese restaurant ("yum cha")? Back when portable game consoles and smartphones were not available, some kids may opt to play with toothpicks, forming figures on the dining table.
Hand-written digits contain curly strokes, but by using the seven-segment display, digits can be represented neatly using only straight segments. The diagram below shows digits $$$0$$$ to $$$9$$$ in seven-segment display:
Alex wants to form a number between $$$0$$$ and $$$99$$$ (inclusive), by using toothpicks as segments in the seven-segment display (one toothpick per segment, naturally). He insists on forming exactly using two digits, so $$$0$$$ will be written as $$$00$$$, $$$1$$$ will be written as $$$01$$$, and so on.
Assume the tens digit is $$$X$$$ and the ones digit is $$$Y$$$. To use fewer toothpicks, Alex invents a rule for merging $$$X$$$ and $$$Y$$$. First, Alex defines the left part of a digit as the two vertical segments on its left. Similar for right part. Refer to the following diagram.
If the right part of $$$X$$$ and the left part of $$$Y$$$ are the same, then the parts can be merged, allowing a more compact and toothpick-friendly representation. See the following example.
There is one exception to this rule. As you may have noticed, if $$$X = 1$$$, then after merging it will look like one single digit. Therefore, Alex will not merge the two digits if the tens digit $$$X$$$ equals $$$1$$$.
Alex is trying to form $$$T$$$ numbers. For each number, determine the number of toothpicks needed to form the number. Whenever digit-merging is possible, Alex will merge the digits.
The first line of input consists of an integer $$$T$$$, the number of queries.
$$$T$$$ lines follow. On the $$$i$$$-th line, there is an integer in the range $$$[0, 99]$$$, representing the $$$i$$$-th number that Alex wants to form. Leading zeroes will be added to integers smaller than $$$10$$$, so that each line consists of two digits.
Other than the sample, your program will be judged on exactly one other test case. For that test case, $$$T = 100$$$.
Output $$$T$$$ lines. On the $$$i$$$-th line, output one integer, the number of toothpicks needed to form the $$$i$$$-th number.
8
10
00
24
88
89
75
33
11
8
10
8
12
13
8
10
4