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: 

<image>

However, Alice evaluates it as shown: 

<image>

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: 

<image>
#######################################################################################################
#######        ###########         #######    #########    #######           ######               #####
######  ######  #########  ######  #######  ###########  #############   ################  ############
######  #######  ########  #######  ######  ###########  ##############  ################  ############
######  ######  #########  #######  ######               #############   ################  ############
######  ###   ###########  #######  ######  ###########  #############   ################  ############
######  #####  ##########  #######  ######  ###########  #############   ################  ############
######  ######  ##########  #####  #######  ###########  #############   ################  ############
####     ######     ######        ######    ########      #######            ##########     ###########
#######################################################################################################
import math
import sys
#-----------------------IMPORTANT  FUNCTIONS ---------------------------------#
from math import cos, pi, ceil, pi, tan, floor, gcd, sqrt, log2, factorial, log10
from collections import Counter
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase
from statistics import mean, median, mode
from bisect import *

alpha = ascii_lowercase
beta = ascii_uppercase


#-----------------------NEXT POWER OF 2---------------------------------------#
def nextPowerOf2(n):
    p = 1
    if (n and not (n & (n - 1))):
        return n
    while (p < n):
        p <<= 1
    return p


#-----------------------GET DIVISORS 1 TO <=N   ------------------------------#
def get_Divisors(n):
    arr = []
    i = 1
    while i <= sqrt(n):
        if (n % i == 0):
            if (n / i == i):
                arr.append(i)
            else:
                arr.append(i)
                arr.append(n // i)
        i = i + 1

    return arr


#----------------------CHECK    PRIMES-----------------------------------#
def isprime(n):
    if n == 1:
        return 0
    i = 2
    while (i * i <= n):
        if (n % i == 0):
            return 0
        i += 1
    return 1


#-----------------------PRE COMPUTED  PRIMES-----------------------------------#
def Sieve(n):
    prime = [True for i in range(n + 1)]
    prime[0] = False
    prime[1] = False
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n + 1, p):
                prime[i] = False
        p += 1
    return prime


#-----------------------LARGER VALUE OF  X,Y,10**9+7 --------------------------#
def power(x, y, p):
    res = 1
    x = x % p
    if (x == 0):
        return 0
    while (y > 0):
        if ((y & 1) == 1):
            res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res


#-----------------------       CREATE MATRIX         --------------------------#
def create_matrix(n, m):
    mat = [[] for i in range(n)]
    for i in range(n):
        for j in range(m):
            mat[i].append(0)
    return mat


#By Default Counter stores the value in decending orderCounter({4: 2, 8: 2, 2: 1, 9: 1}
#s=sorted(s.items(),key=lambda k:(k[0],k[1])) ---> [(2, 1), (4, 2), (8, 2), (9, 1)]
#sort 2nd value  from bada se chhota  then(4,2)(8,2)->>(8,2)(4,2) s=sorted(s.items(),key=lambda k:(-k[1],-k[0]))  [(8, 2), (4, 2), (9, 1), (2, 1)]
#for list pair in a list    s.sort(key=lambda k:(-k[1],-k[0])) [[3, 4], [8, 2], [4, 2]]
# from functools import cmp_to_key
# def compare(x, y):
#     if x + y > y + x:
#         return -1
#     elif x + y < y + x:
#         return 1
#     else:
#         return 0
#how to use compare ----ss = sorted(s, key=cmp_to_key(compare))
# a=[1,4,5,9,12,15]
# print(bisect(a,9))
# insort(a,9)
# print(a)
#arr=[-14,-10,2,108,108,243,285,285,401]
# print(bisect_left(arr,-10))
# print(bisect_left(arr,108))
# print(bisect_left(arr,501))
# print(bisect_left(arr,200))
# print(bisect_left(arr,-20))
#**************************************
# print(bisect_right(arr,-10))
# print(bisect_right(arr,108))
# print(bisect_right(arr,501))
# print(bisect_right(arr,200))
# print(bisect_right(arr,-20))
#-----------------------*****CODE STARTS  HERE*****--------------------------#
# sys.stdout = open('ot.txt', 'w')
# sys.stdin = open('in.txt', 'r')
def main():
    for ttt in range(int(input())):
        n =(input().strip())
        if len(n)<=1:
            print(int(n)-1)
            continue
        s=""
        t=""
        for i in range(len(n)):
            if i%2:
                t+=n[i]
            else:
                s+=n[i]
        print((int(s)+1)*(int(t)+1)-2)
                
        
if __name__ == "__main__":
    main()