human
PYTHON3 solution for "Alice has just learned addition. However, she hasn't learned the concept of "carrying" fully — instead of carrying to the next column, she carries to the column two columns to the left.

For example, the regular way to evaluate the sum 2039 + 2976 would be as shown: 


However, Alice evaluates it as shown: 


In particular, this is what she does: 

  * add 9 and 6 to make 15, and carry the 1 to the column two columns to the left, i. e. to the column "0 9".

  * add 3 and 7 to make 10 and carry the 1 to the column two columns to the left, i. e. to the column "2 2".

  * add 1, 0, and 9 to make 10 and carry the 1 to the column two columns to the left, i. e. to the column above the plus sign.

  * add 1, 2 and 2 to make 5.

  * add 1 to make 1. 

Thus, she ends up with the incorrect result of 15005.

Alice comes up to Bob and says that she has added two numbers to get a result of n. However, Bob knows that Alice adds in her own way. Help Bob find the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n. Note that pairs (a, b) and (b, a) are considered different if a ≠ b.

Input

The input consists of multiple test cases. The first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.

The only line of each test case contains an integer n (2 ≤ n ≤ 10^9) — the number Alice shows Bob.

Output

For each test case, output one integer — the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n. 

Example

Input

5
100
12
8
2021
10000

Output

9
4
7
44
99

Note

In the first test case, when Alice evaluates any of the sums 1 + 9, 2 + 8, 3 + 7, 4 + 6, 5 + 5, 6 + 4, 7 + 3, 8 + 2, or 9 + 1, she will get a result of 100. The picture below shows how Alice evaluates 6 + 4: 

":



=====
Write me a Python program to find the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n?
assistant
#Here is Python program to find the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n.
 def main():
    mod=1000000007
    # mod=998244353
    # nCr =  make_nCr_mod()
    # LOGIC-
    # Editorial is good enough
    tc=ri()
    for i in range(tc):
        s=rs()
        size=len(s)
        n1,n2=0,0
        for i in range(0,size,2):
            n1=n1*10+int(s[i])
        for i in range(1,size,2):
            n2=n2*10+int(s[i])
        wi((n1+1)*(n2+1)-2)
        
def rant():
    # RANT BEGINS-
    # 
    # Did you look at the constraints dummy? Read problem again carefully understand it correctly
    # Are base cases correct n=0,n=1,n=N or string is all 0 or all 1?
    # Take hints from time limits maybe n=1000 and m=100000 so if n^2 doesnt work n*m might work?? 
    # Upto 10^8 works under 2 sec
    # 
    # 1.Greedy? What matters what doesnt? Is my claim correct? 
    #   Does my implementation correctly implements the greedy i thought of? 
    #   Dictionary? keep a count of values if constraint on something is low(like only alphabets(26) count)? 
    # 
    # 2.DP? Think about state's ranges maybe one of the states have lesser possible values than it may look like? 
    #   Obviously think about order of evaluation
    # 
    # 3.Binary Search?(Monotonic? any one directed order in which we have to perform something?)
    # 
    # 4.Graph?DSU?Edge property or Vertex property Read carefully? Bipartitenes Property??? Cycle Property??? 
    #   Hidden but dependency ordering of values(in 1d array or 2d Table/Array) is that of a graph???
    # 
    # 5.Number Theory?(GCD subtraction?)
    # 
    # 6.Bruteforce?(Redundant part of N which may not give answer?Constraints?)
    # 
    # 7.Range Queries?
    # 
    # 8.Any Equivalency?(We have A and B and have to do 
    #   something between them maybe difficult if there was A~C and C~B then A~B
    #   C could be max or min or some other thing)
    # 
    # 9.Reverse Engineering?(From Answer to quesn or last step to first step)
    #
    # 10.Constructive? Mod? Bruteforce for smaller case and analyze patterns?
    #
    # 11.String? Constructive...