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 itertools as _itertools
import sys as _sys


def how_many_inputs_give_same_result_for_alice_addition(alice_additon_result):
    if not isinstance(alice_additon_result, int):
        raise TypeError
    alice_additon_result = int(alice_additon_result)
    
    if alice_additon_result < 2:  # Because only positive terms allowed
        return 0
    
    # Same term for digits addition modulo 10
    # But 10 times higher "other" term
    # Same rule for decrement?
    
    # Maybe can iterate through "other" terms?
    
    result = 0
    digits_n = len(str(alice_additon_result))
    for other_term_div_100_digits in _itertools.product('01', repeat=digits_n):
        current_variants_n = 1
        
        other_term_div_100 = int(''.join(other_term_div_100_digits))
        try:
            mod_addition_result = _alice_sub(alice_additon_result, 100*other_term_div_100)
        except ValueError:
            continue
        
        mod_term_digits = str(mod_addition_result).zfill(digits_n)
        for digits_sum_mod_10, digits_sum_div_10 in zip(mod_term_digits, other_term_div_100_digits):
            digits_sum_mod_10 = int(digits_sum_mod_10)
            digits_sum_div_10 = int(digits_sum_div_10)
            if digits_sum_div_10 == 0:
                first_digit_available = 0
                last_digit_available = digits_sum_mod_10
            else:
                assert digits_sum_div_10 == 1
                first_digit_available = digits_sum_mod_10 + 10 - 9
                last_digit_available = 9
            current_variants_n *= len(range(first_digit_available, last_digit_available+1))
        
        result += current_variants_n
    
    return result - 2


def _alice_sub(a, b):
    if not (0 <= b <= a):
        raise ValueError
    
    digits_n = max(len(str(a)), len(str(b)))
    
    a_digits = [int(d) for d in str(a).zfill(digits_n)]
    b_digits = [int(d) for d in str(b).zfill(digits_n)]
    
    a_digits.reverse()
    b_digits.reverse()
    
    result = 0
    for i_digit in range(digits_n):
        power_of_10 = 10 ** i_digit
        a_d = a_digits[i_digit]
        b_d = b_digits[i_digit]
        delta = a_d - b_d
        result += delta % 10 * power_of_10
        if delta < 0:
            try:
                b_digits[i_digit + 2] += 1
            except IndexError:
                raise ValueError
    
    return result


def _main():
    [tests_n] = _read_ints()
    for i_test in range(tests_n):
        [alice_additon_result] = _read_ints()
        result = how_many_inputs_give_same_result_for_alice_addition(alice_additon_result)
        print(result)


def _read_ints(file=_sys.stdin):
    return map(int, file.readline().split())


if __name__ == '__main__':
    _main()
