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 time
import os,sys
from datetime import datetime
from math import floor,sqrt,gcd,factorial,ceil,log2
from collections import Counter,defaultdict
import bisect
from itertools import chain
from collections import deque
from sys import maxsize as INT_MAX
from itertools import permutations
#import threading
'''Dont use setrecursionlimit in pypy'''
#sys.setrecursionlimit(int(1e9)+500)
#threading.stack_size(0x2000000)
ONLINE_JUDGE,INF,mod=False,float('inf'),int(1e9)+7
if os.path.exists('D:\\vimstuff'):
	ONLINE_JUDGE=True
	sys.stdin=open('inp.txt','r')
	sys.stdout=open('out.txt','w')
'''def ceil(a,b):
	return(int((a+b-1)/b))'''

def readint():
	return int(sys.stdin.readline())
def readstr():
	return sys.stdin.readline()
def readlst():
	return list(map(int, sys.stdin.readline().strip().split()))
def readmul():
	return map(int, sys.stdin.readline().strip().split())
def mulfloat():	return map(float, sys.stdin.readline().strip().split())
def flush():
	return sys.stdout.flush()
def power_two(x):
	return (1<<x)
def lcm(a,b):
	return a*b//gcd(a,b)

def countGreater(arr,n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while (l <= r):
		m = int(l + (r - l) / 2)
		if (arr[m] >= k):
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
			return (n - leftGreater)

def lower_bound(arr,n,val):
	l,r=-1,n
	while r>l+1:
		m=int((l+r)>>1)
		if arr[m]<val:
			l=m
		else:
			r=m
	return r

def upper_bound(arr,n,val):
	l,r=-1,n
	while r>l+1:
		m=int((l+r)>>1)
		if arr[m]<=val:
			l=m
		else:
			r=m
	return l

def binpow(a,n,mod):
	res=1
	while n:
		if n&1:
			res=(res*a)%mod
			n-=1
		a=(a*a)%mod
		n=n>>1
	return res

def printmat(l,seperate=True):
	for i in range(0,len(l)):
		if(seperate):
			print(*l[i],sep=" ")
		else:
			print(*l[i],sep="")


'''
c-space = to copy
o-space= to open file
,-space=to run prog
:noh= to get rid of text highlight

1. Implement after understanding properly don't do in vain.
2. Check corner cases.
3. Use python if there is recursion,try-catch,dictionary.
4. Use pypy if heavy loop,list slice.
'''
def isperfect(num):
	if floor(sqrt(num))==ceil(sqrt(num)):
		return True
	return False

def john_3_16():
    num=readint()
    if(num<10):
    	print(num-1)
    else:
    	if(isperfect(num)):
    		print(int(sqrt(num))-1)
    	elif(num&1):
    		print(floor(sqrt(num)))
    	else:
    		print(ceil(sqrt(num)))

    return
    


def main():
	#print(xors[0:5])
	tc=readint()
	#tc=1
	#cnt=0
	start=time.time()
	#cnt=1
	while tc:
		john_3_16()
		tc-=1
		#cnt+=1
	if ONLINE_JUDGE:
		print(f'{(time.time()-start)*1000}ms')
		pass
main()


