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 \ne b$.


-----Input-----

The input consists of multiple test cases. The first line contains an integer $t$ ($1 \leq t \leq 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 \leq n \leq 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$.


-----Examples-----

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$:

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Dynamic programming

Bit manipulation

Combinatorics

Mathematics


Solutions:
for s in [*open(0)][1:]:
	print((int(s[::2]) + 1) * (int('0' + s[1::2]) + 1) - 2)


t = int(input())
while t:
	t -= 1
	n = input()
	s1 = ''
	s2 = ''
	for i in range(len(n)):
		if i % 2 == 0:
			s1 += str(n[i])
		else:
			s2 += str(n[i])
	i = j = 0
	while i < len(s1) and s1[i] == '0':
		i += 1
	while j < len(s2) and s2[j] == '0':
		j += 1
	s1 = s1[i:]
	s2 = s2[j:]
	if len(s1) == 0:
		s1 = 0
	else:
		s1 = int(s1)
	if len(s2) == 0:
		s2 = 0
	else:
		s2 = int(s2)
	print((int(s1) + 1) * (int(s2) + 1) - 2)


for _ in range(int(input())):
	n = '0' + input()
	a = int(n[0::2])
	b = int(n[1::2])
	print((a + 1) * (b + 1) - 2)


n = int(input())
for _ in range(n):
	num1 = 0
	num2 = 0
	num = input()
	for i in range(len(num)):
		if i % 2 == 0:
			num1 = num1 * 10 + int(num[i])
		else:
			num2 = num2 * 10 + int(num[i])
	result = (num1 + 1) * (num2 + 1) - 2
	print(result)


def read_line():
	return [int(x) for x in input().split()]

def read_int():
	return int(input())

def solve():
	n = read_int()
	s = str(n)
	a = ''
	b = ''
	for i in range(0, len(s)):
		if i & 1:
			a += s[i]
		else:
			b += s[i]
	if a:
		a = int(a)
	else:
		a = 0
	if b:
		b = int(b)
	else:
		b = 0
	print((a + 1) * (b + 1) - 2)
t = read_int()
while t > 0:
	solve()
	t -= 1


for _ in range(int(input())):
	n = int(input())
	i = 1
	(a, b) = (0, 0)
	while n:
		a += n % 10 * i
		n //= 10
		b += n % 10 * i
		n //= 10
		i *= 10
	if a == 0 or b == 0:
		print(max(a - 1, b - 1))
	else:
		print((a + 1) * (b + 1) - 2)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
import collections
from itertools import permutations
from itertools import combinations

def prob():
	s = input()
	n = len(s)
	if n == 1:
		print(int(s) - 1)
		return
	a = ''
	b = ''
	for i in range(0, n, 2):
		a += s[i]
	for i in range(1, n, 2):
		b += s[i]
	x = int(a) + 1
	y = int(b) + 1
	print(x * y - 2)
t = 1
t = int(input())
for _ in range(0, t):
	prob()


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:
		return 0
	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
		for (digits_sum_mod_10, digits_sum_div_10) in zip(str(mod_addition_result).zfill(len(other_term_div_100_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):
	assert b >= 0
	if b > a:
		raise ValueError
	digits_n = len(str(a))
	a_digits = [int(d) for d in str(a)]
	b_digits = [int(d) for d in str(b).zfill(digits_n)]
	result = 0
	for power_of_10 in range(digits_n):
		a_d = a_digits[-1 - power_of_10]
		b_d = b_digits[-1 - power_of_10]
		delta = a_d - b_d
		result += delta % 10 * 10 ** power_of_10
		if delta < 0:
			try:
				b_digits[-1 - power_of_10 - 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())
_main()


from collections import deque
import heapq

class Solution:

	@staticmethod
	def solve():
		t = int(input())
		while t:
			t -= 1
			n = input()
			a = b = '0'
			for i in range(len(n)):
				if i % 2 == 0:
					a += n[i]
				else:
					b += n[i]
			ans = (int(a) + 1) * (int(b) + 1) - 2
			print(ans)
Solution.solve()


import os, sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd
from _collections import deque
import heapq as hp
from bisect import bisect_left, bisect_right
from math import cos, sin
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	a = [i for i in str(n)]
	b = ['0']
	c = ['0']
	for i in range(len(a)):
		if i % 2:
			b.append(a[i])
		else:
			c.append(a[i])
	print((int(''.join(b)) + 1) * (int(''.join(c)) + 1) - 2)


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
(ONLINE_JUDGE, INF, mod) = (False, float('inf'), int(1000000000.0) + 7)
if os.path.exists('D:\\Contest'):
	ONLINE_JUDGE = True
	sys.stdin = open('inp.txt', 'r')
	sys.stdout = open('out.txt', 'w')

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='')

def is_perfect_square(num):
	temp = num ** 0.5
	return temp // 1 == temp

def john_3_16():
	s = input()
	(a, b) = ('', '')
	for i in range(0, len(s)):
		if i & 1:
			b += s[i]
		else:
			a += s[i]
	if len(s) > 1:
		(a, b) = (int(a), int(b))
		print((a + 1) * (b + 1) - 2)
	else:
		print(int(a) - 1)
	return

def main():
	tc = readint()
	start = time.time()
	while tc:
		john_3_16()
		tc -= 1
	if ONLINE_JUDGE:
		print(f'{(time.time() - start) * 1000}ms')
		pass
main()


from __future__ import division, print_function
import math
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return int(input())

def inps():
	return input().strip()

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	n = inp()
	s = str(n)
	ln = len(s)
	(a, b) = (0, 0)
	for i in range(ln):
		if i % 2 == 0:
			a = a * 10 + int(s[i])
		else:
			b = b * 10 + int(s[i])
	print((b + 1) * (a + 1) - 2)


from math import *
import os
import random
import re
import sys
from itertools import *
m = pow(10, 9) + 7
for t in range(int(input())):
	S = str(int(input()))[::-1]
	if len(S) == 1:
		print(int(S) - 1)
		continue
	s1 = ''
	s2 = ''
	for i in range(len(S)):
		if i % 2 == 0:
			s1 += S[i]
		else:
			s2 += S[i]
	print((int(s1[::-1]) + 1) * (int(s2[::-1]) + 1) - 2)


import sys

def solve(num):
	a = str(num)
	b = a[::2]
	if not b:
		even = 0
	else:
		even = int(b)
	c = a[1::2]
	if not c:
		odd = 0
	else:
		odd = int(c)
	return (odd + 1) * (even + 1) - 2
first = True
for line in sys.stdin.readlines():
	if first:
		first = False
		continue
	n = int(line)
	print(solve(n))


import math
for _ in range(int(input())):
	n = input()
	s1 = ''
	s2 = ''
	for i in range(0, len(n), 2):
		s1 += n[i]
	for i in range(1, len(n), 2):
		s2 += n[i]
	if len(s1) > 0:
		z1 = int(s1) + 1
	else:
		z1 = 1
	if len(s2) > 0:
		z2 = int(s2) + 1
	else:
		z2 = 1
	ans = z1 * z2 - 2
	print(max(0, ans))


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import sys
import string
import random
from typing import List
sys.setrecursionlimit(99999)
t = int(input())
for _ in range(t):
	n = int(input())
	d1 = collections.defaultdict(int)
	d2 = collections.defaultdict(int)
	d1[0] = 1
	d2[0] = 1
	while n:
		c = n % 10
		n //= 10
		nd = collections.defaultdict(int)
		for dt in d1:
			for a in range(10):
				for b in range(10):
					cur = dt + a + b
					if cur % 10 == c:
						nd[cur // 10] += d1[dt]
		d1 = d2
		d2 = nd
	print(d1[0] * d2[0] - 2)


def solve():
	k = input()
	if len(k) == 1:
		print(int(k) - 1)
		return
	print((int(k[::2]) + 1) * (int(k[1::2]) + 1) - 2)
n = int(input())
for i in range(n):
	solve()


t = int(input())
for _ in range(t):
	sn = input()
	s1 = sn[::2]
	s2 = sn[1::2]
	c1 = 0
	for c in s1:
		c1 = c1 * 10 + ord(c) - ord('0')
	c2 = 0
	for c in s2:
		c2 = c2 * 10 + ord(c) - ord('0')
	print((c1 + 1) * (c2 + 1) - 2)


def main():
	mod = 1000000007
	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():
	return 'AAAAAAAAAAAAAAAAARRRGHHHHHHHHHHHHHHHHHHHHHHHH'

def position_dict(arr):
	posn = {}
	for i in range(len(arr)):
		if arr[i] in posn:
			posn[arr[i]].append(i)
		else:
			posn[arr[i]] = [i]
	return posn

def SieveOfEratosthenes(limit):
	isPrime = [True] * (limit + 1)
	isPrime[0] = isPrime[1] = False
	primes = []
	for i in range(2, limit + 1):
		if not isPrime[i]:
			continue
		primes += [i]
		for j in range(i * i, limit + 1, i):
			isPrime[j] = False
	return primes

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return math.gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = math.gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = math.gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def distinct_factors(n):
	factors = [1]
	for (p, exp) in prime_factors(n).items():
		factors += [p ** i * factor for factor in factors for i in range(1, exp + 1)]
	return factors

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def make_nCr_mod(max_n=2 * 10 ** 5, mod=10 ** 9 + 7):
	max_n = min(max_n, mod - 1)
	(fact, inv_fact) = ([0] * (max_n + 1), [0] * (max_n + 1))
	fact[0] = 1
	for i in range(max_n):
		fact[i + 1] = fact[i] * (i + 1) % mod
	inv_fact[-1] = pow(fact[-1], mod - 2, mod)
	for i in reversed(range(max_n)):
		inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod

	def nCr_mod(n, r):
		res = 1
		while n or r:
			(a, b) = (n % mod, r % mod)
			if a < b:
				return 0
			res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod
			n //= mod
			r //= mod
		return res
	return nCr_mod

class DisjointSetUnion:

	def __init__(self, n):
		self.parent = [*range(n + 1)]
		self.size = [1] * (n + 1)
		(self.min, self.max) = ([*range(n + 1)], [*range(n + 1)])
		self.count = n

	def get(self, a):
		if self.parent[a] == a:
			return a
		x = a
		while a != self.parent[a]:
			a = self.parent[a]
		while x != self.parent[x]:
			(self.parent[x], x) = (a, self.parent[x])
		return a

	def union(self, a, b):
		(a, b) = (self.get(a), self.get(b))
		if a != b:
			if self.size[a] > self.size[b]:
				(a, b) = (b, a)
			self.parent[a] = b
			self.size[b] += self.size[a]
			self.min[b] = min(self.min[a], self.min[b])
			self.max[b] = max(self.max[a], self.max[b])
			self.count -= 1

	def count_sets(self):
		return self.count

class SegmentTree:

	def __init__(self, data, default=0, func=max):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		stop += 1
		start += self._size
		stop += self._size
		res_left = res_right = self._default
		while start < stop:
			if start & 1:
				res_left = self._func(res_left, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res_right = self._func(self.data[stop], res_right)
			start >>= 1
			stop >>= 1
		return self._func(res_left, res_right)

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SparseTable:

	def __init__(self, data, func=min):
		self.func = func
		self._data = _data = [list(data)]
		(i, n) = (1, len(_data[0]))
		while 2 * i <= n:
			prev = _data[-1]
			_data.append([func(prev[j], prev[j + i]) for j in range(n - 2 * i + 1)])
			i <<= 1

	def query(self, start, stop):
		depth = (stop + 1 - start).bit_length() - 1
		return self.func(self._data[depth][start], self._data[depth][stop + 1 - (1 << depth)])

	def __getitem__(self, idx):
		return self._data[0][idx]

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))
import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from math import log2
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
INF = 999999999999999999999999
alphabets = 'abcdefghijklmnopqrstuvwxyz'

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
starttime = datetime.datetime.now()
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
main()
endtime = datetime.datetime.now()
time = (endtime - starttime).total_seconds() * 1000
if os.path.exists('input.txt'):
	print('Time:', time, 'ms')


def func():
	n = input()
	n1 = ''
	n2 = ''
	l = len(n)
	for i in range(l):
		if i % 2 == 0:
			n1 += n[i]
		else:
			n2 += n[i]
	if len(n2) == 0:
		print(int(n1) - 1)
		return
	n1 = int(n1)
	n2 = int(n2)
	print((n1 + 1) * (n2 + 1) - 2)
t = int(input())
for i in range(t):
	func()


j = int(input())
for k in range(j):
	t = input()
	a = ''
	b = ''
	for i in range(len(t)):
		if i % 2:
			a += t[i]
		else:
			b += t[i]
	if len(a) > 0:
		c = int(a)
	else:
		c = 0
	if len(b) > 0:
		d = int(b)
	else:
		d = 0
	print((c + 1) * (d + 1) - 2)


def prob():
	s = input()
	n = len(s)
	if n == 1:
		print(int(s) - 1)
		return
	a = ''
	b = ''
	for i in range(0, n, 2):
		a += s[i]
	for i in range(1, n, 2):
		b += s[i]
	x = int(a) + 1
	y = int(b) + 1
	print(x * y - 2)
t = 1
t = int(input())
for _ in range(0, t):
	prob()


import sys
read = lambda : sys.stdin.readline()
for _ in range(int(read())):
	a = read()
	if int(a) < 10:
		print(int(a) - 1)
		continue
	num1 = int(''.join([a[i] for i in range(0, len(a), 2)]))
	num2 = int(''.join([a[i] for i in range(1, len(a), 2)]))
	print((num1 + 1) * (num2 + 1) - 2)


t = int(input())
for _ in range(t):
	s = input()[::-1]
	odd = even = ''
	k = len(s)
	for i in range(0, k, 2):
		odd += s[i]
		if i + 1 < k:
			even += s[i + 1]
	odd = odd[::-1]
	even = even[::-1]
	if even == '':
		even = '0'
	odd = int(odd)
	even = int(even)
	ans = (odd + 1) * (even + 1) - 2
	print(ans)


t = int(input())
for t in range(t):
	n = input()
	a = 0
	b = 0
	for i in range(len(n)):
		if i % 2 == 0:
			a = a * 10 + int(n[i])
		else:
			b = b * 10 + int(n[i])
	print((a + 1) * (b + 1) - 2)


for _ in range(int(input())):
	n = input()
	l = len(n)
	if l == 1:
		print(int(n) - 1)
	else:
		(a, b) = (int(n[::2]), int(n[1::2]))
		if l & 1 == 0:
			(a, b) = (b, a)
		print((a + 1) * (b + 1) - 2)


def solver(num1, num2):
	num1 = int(num1)
	num2 = int(num2)
	total1 = num1 + 1
	total2 = num2 + 1
	total = total1 * total2
	tosub = 0
	if num1 != 0 and num2 != 0:
		return total - 2
	if num1 == 0 and num2 != 0:
		return total - 2
	if num1 != 0 and num2 == 0:
		return total - 2
	if num1 == 0 and num2 == 0:
		return 0

def lastsolver(train):
	length = len(train)
	if len(train) == 1:
		if int(train) > 1:
			print(int(train) - 1)
			return int(train) - 1
		else:
			print(0)
			return 0
	if len(train) % 2 == 0:
		l1 = length // 2
		l2 = length // 2
		num1 = ''
		num2 = ''
		for i in range(l1):
			num1 = num1 + str(train[2 * i])
		for i in range(l2):
			num2 = num2 + str(train[2 * i + 1])
		print(solver(num1, num2))
		return solver(num1, num2)
	else:
		l1 = length // 2
		l2 = length // 2 + 1
		num1 = ''
		num2 = ''
		for i in range(l1):
			num1 = num1 + str(train[2 * i + 1])
		for i in range(l2):
			num2 = num2 + str(train[2 * i])
		print(solver(num1, num2))
		return solver(num1, num2)
t = int(input())
for i in range(t):
	current = input()
	lastsolver(current)


def answer():
	n = list(input())
	s1 = ''
	s2 = ''
	for i in range(len(n)):
		if i % 2 == 0:
			s1 += n[i]
		else:
			s2 += n[i]
	if s2 == '':
		print(int(n[0]) - 1)
		return
	ans = 0
	x1 = int(s1)
	x2 = int(s2)
	if x2 == 0:
		ans = x1 - 1
	else:
		ans = (x1 - 1) * (x2 + 1)
		ans += 2 * x2
	print(ans)
t = int(input())
for _ in range(t):
	answer()


t = int(input())
for k in range(t):
	n = input()
	if len(n) == 1:
		print(int(n) - 1)
		continue
	(n1, n2) = ('', '')
	for i in range(len(n)):
		if i % 2 == 0:
			n1 += n[i]
		else:
			n2 += n[i]
	n1 = int(n1)
	n2 = int(n2)
	print((n1 + 1) * (n2 + 1) - 2)


t = int(input())
for q in range(t):
	a = input()
	t = '0'
	s = '0'
	for i in range(len(a)):
		if i % 2 == 0:
			t += a[i]
		else:
			s += a[i]
	print((int(t) + 1) * (int(s) + 1) - 2)


for _ in range(int(input())):
	n = int(input())
	s = str(n)
	len2 = len(s) - 2
	if len(s) == 1:
		print(int(s[-1]) - 1)
		continue
	if len(s) == 2:
		print((int(s[-1]) + 1) * (int(s[-2]) + 1) - 2)
		continue
	ans = -2
	for x in range(1 << len2):
		b = '0b' + bin(x)[:1:-1] + '0' * 10
		cur = 1
		failed = False
		for i in range(2):
			if i + 2 < len(s) and b[i + 2] == '1':
				cur *= int(s[i])
			else:
				cur *= int(s[i]) + 1
		for i in range(2, len(s)):
			if b[i] == '1' and s[i - 2] == '0' and (b[i - 2] != '1'):
				failed = True
				break
			if b[i] == '1':
				if i + 2 < len(s) and b[i + 2] == '1':
					cur *= 10 - int(s[i])
				else:
					if s[i] == '9':
						failed = True
						break
					cur *= 9 - int(s[i])
			elif i + 2 < len(s) and b[i + 2] == '1':
				cur *= int(s[i])
			else:
				cur *= int(s[i]) + 1
		if not failed:
			ans += cur
	print(ans)


def solve():
	s = input()
	(s1, s2) = ('', '')
	for i in range(len(s)):
		if i % 2 == 0:
			s1 += s[i]
		else:
			s2 += s[i]
	if not s2:
		print(int(s1) - 1)
	else:
		print((int(s1) + 1) * (int(s2) + 1) - 2)
	return
t = int(input())
while t > 0:
	t -= 1
	solve()


for _ in range(int(input())):
	s = input()
	a = ''
	b = ''
	for i in range(len(s)):
		if i % 2 == 0:
			a += s[i]
		else:
			b += s[i]
	if len(b) == 0:
		print(int(a) - 1)
	else:
		print((int(a) + 1) * (int(b) + 1) - 2)


from heapq import heappush, heappop

def solve(a, b):
	if a == 0 and b == 0:
		return 0
	total = (a + 1) * (b + 1)
	return total - 2
t = int(input())
for _ in range(t):
	n = list(input())
	a = []
	b = []
	for i in range(len(n)):
		if i % 2 == 0:
			a.append(n[i])
		else:
			b.append(n[i])
	a = ''.join(a)
	b = ''.join(b)
	a = int(a) if a != '' else 0
	b = int(b) if b != '' else 0
	print(solve(a, b))


ways = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

def solve(n, d=0, c=[]):
	if n == 0:
		return len(c) == 0
	num = n % 10
	if d in c:
		num -= 1
		c.remove(d)
	s1 = solve(n // 10, d + 1, c[:])
	s2 = solve(n // 10, d + 1, c + [d + 2])
	return (ways[num] * s1 if num >= 0 else 0) + (ways[10 + num] * s2 if 10 + num <= 18 else 0)
t = int(input())
for _ in range(t):
	n = int(input())
	print(solve(n) - 2)


def check(num, i):
	ans = 1
	b = [0, 0]
	for j in range(8):
		b.append(i & 1)
		i = i >> 1
	flag = True
	for j in range(9, -1, -1):
		t = num[j] + (b[j + 2] * 10 if j + 2 < 10 else 0)
		if b[j] == 1 and t == 0:
			return 0
		tmp = t - b[j]
		if tmp > 9:
			flag = False
		ans *= tmp + 1 if tmp < 10 else 19 - tmp
	return ans - (2 if flag else 0)
for test in range(int(input())):
	n = int(input())
	num = [n // 10 ** i % 10 for i in range(10)]
	ans = 0
	for i in range(2 ** 8):
		ans += check(num, i)
	print(ans)


def divisors(M):
	d = []
	i = 1
	while M >= i ** 2:
		if M % i == 0:
			d.append(i)
			if i ** 2 != M:
				d.append(M // i)
		i = i + 1
	return d

def popcount(x):
	x = x - (x >> 1 & 1431655765)
	x = (x & 858993459) + (x >> 2 & 858993459)
	x = x + (x >> 4) & 252645135
	x = x + (x >> 8)
	x = x + (x >> 16)
	return x & 127

def eratosthenes(n):
	res = [0 for i in range(n + 1)]
	prime = set([])
	for i in range(2, n + 1):
		if not res[i]:
			prime.add(i)
			for j in range(1, n // i + 1):
				res[i * j] = 1
	return prime

def factorization(n):
	res = []
	for p in prime:
		if n % p == 0:
			while n % p == 0:
				n //= p
			res.append(p)
	if n != 1:
		res.append(n)
	return res

def euler_phi(n):
	res = n
	for x in range(2, n + 1):
		if x ** 2 > n:
			break
		if n % x == 0:
			res = res // x * (x - 1)
			while n % x == 0:
				n //= x
	if n != 1:
		res = res // n * (n - 1)
	return res

def ind(b, n):
	res = 0
	while n % b == 0:
		res += 1
		n //= b
	return res

def isPrimeMR(n):
	d = n - 1
	d = d // (d & -d)
	L = [2, 3, 5, 7, 11, 13, 17]
	for a in L:
		t = d
		y = pow(a, t, n)
		if y == 1:
			continue
		while y != n - 1:
			y = y * y % n
			if y == 1 or t == n - 1:
				return 0
			t <<= 1
	return 1

def findFactorRho(n):
	from math import gcd
	m = 1 << n.bit_length() // 8
	for c in range(1, 99):
		f = lambda x: (x * x + c) % n
		(y, r, q, g) = (2, 1, 1, 1)
		while g == 1:
			x = y
			for i in range(r):
				y = f(y)
			k = 0
			while k < r and g == 1:
				ys = y
				for i in range(min(m, r - k)):
					y = f(y)
					q = q * abs(x - y) % n
				g = gcd(q, n)
				k += m
			r <<= 1
		if g == n:
			g = 1
			while g == 1:
				ys = f(ys)
				g = gcd(abs(x - ys), n)
		if g < n:
			if isPrimeMR(g):
				return g
			elif isPrimeMR(n // g):
				return n // g
			return findFactorRho(g)

def primeFactor(n):
	i = 2
	ret = {}
	rhoFlg = 0
	while i * i <= n:
		k = 0
		while n % i == 0:
			n //= i
			k += 1
		if k:
			ret[i] = k
		i += 1 + i % 2
		if i == 101 and n >= 2 ** 20:
			while n > 1:
				if isPrimeMR(n):
					(ret[n], n) = (1, 1)
				else:
					rhoFlg = 1
					j = findFactorRho(n)
					k = 0
					while n % j == 0:
						n //= j
						k += 1
					ret[j] = k
	if n > 1:
		ret[n] = 1
	if rhoFlg:
		ret = {x: ret[x] for x in sorted(ret)}
	return ret

def divisors(n):
	res = [1]
	prime = primeFactor(n)
	for p in prime:
		newres = []
		for d in res:
			for j in range(prime[p] + 1):
				newres.append(d * p ** j)
		res = newres
	res.sort()
	return res

def xorfactorial(num):
	if num == 0:
		return 0
	elif num == 1:
		return 1
	elif num == 2:
		return 3
	elif num == 3:
		return 0
	else:
		x = baseorder(num)
		return 2 ** x * ((num - 2 ** x + 1) % 2) + function(num - 2 ** x)

def xorconv(n, X, Y):
	if n == 0:
		res = [X[0] * Y[0] % mod]
		return res
	x = [X[i] + X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	y = [Y[i] + Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	z = [X[i] - X[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	w = [Y[i] - Y[i + 2 ** (n - 1)] for i in range(2 ** (n - 1))]
	res1 = xorconv(n - 1, x, y)
	res2 = xorconv(n - 1, z, w)
	former = [(res1[i] + res2[i]) * inv for i in range(2 ** (n - 1))]
	latter = [(res1[i] - res2[i]) * inv for i in range(2 ** (n - 1))]
	former = list(map(lambda x: x % mod, former))
	latter = list(map(lambda x: x % mod, latter))
	return former + latter

def merge_sort(A, B):
	(pos_A, pos_B) = (0, 0)
	(n, m) = (len(A), len(B))
	res = []
	while pos_A < n and pos_B < m:
		(a, b) = (A[pos_A], B[pos_B])
		if a < b:
			res.append(a)
			pos_A += 1
		else:
			res.append(b)
			pos_B += 1
	res += A[pos_A:]
	res += B[pos_B:]
	return res

class UnionFindVerSize:

	def __init__(self, N):
		self._parent = [n for n in range(0, N)]
		self._size = [1] * N
		self.group = N

	def find_root(self, x):
		if self._parent[x] == x:
			return x
		self._parent[x] = self.find_root(self._parent[x])
		stack = [x]
		while self._parent[stack[-1]] != stack[-1]:
			stack.append(self._parent[stack[-1]])
		for v in stack:
			self._parent[v] = stack[-1]
		return self._parent[x]

	def unite(self, x, y):
		gx = self.find_root(x)
		gy = self.find_root(y)
		if gx == gy:
			return
		self.group -= 1
		if self._size[gx] < self._size[gy]:
			self._parent[gx] = gy
			self._size[gy] += self._size[gx]
		else:
			self._parent[gy] = gx
			self._size[gx] += self._size[gy]

	def get_size(self, x):
		return self._size[self.find_root(x)]

	def is_same_group(self, x, y):
		return self.find_root(x) == self.find_root(y)

class WeightedUnionFind:

	def __init__(self, N):
		self.parent = [i for i in range(N)]
		self.size = [1 for i in range(N)]
		self.val = [0 for i in range(N)]
		self.flag = True
		self.edge = [[] for i in range(N)]

	def dfs(self, v, pv):
		stack = [(v, pv)]
		new_parent = self.parent[pv]
		while stack:
			(v, pv) = stack.pop()
			self.parent[v] = new_parent
			for (nv, w) in self.edge[v]:
				if nv != pv:
					self.val[nv] = self.val[v] + w
					stack.append((nv, v))

	def unite(self, x, y, w):
		if not self.flag:
			return
		if self.parent[x] == self.parent[y]:
			self.flag = self.val[x] - self.val[y] == w
			return
		if self.size[self.parent[x]] > self.size[self.parent[y]]:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[x] += self.size[y]
			self.val[y] = self.val[x] - w
			self.dfs(y, x)
		else:
			self.edge[x].append((y, -w))
			self.edge[y].append((x, w))
			self.size[y] += self.size[x]
			self.val[x] = self.val[y] + w
			self.dfs(x, y)

class Dijkstra:

	class Edge:

		def __init__(self, _to, _cost):
			self.to = _to
			self.cost = _cost

	def __init__(self, V):
		self.G = [[] for i in range(V)]
		self._E = 0
		self._V = V

	@property
	def E(self):
		return self._E

	@property
	def V(self):
		return self._V

	def add_edge(self, _from, _to, _cost):
		self.G[_from].append(self.Edge(_to, _cost))
		self._E += 1

	def shortest_path(self, s):
		import heapq
		que = []
		d = [10 ** 15] * self.V
		d[s] = 0
		heapq.heappush(que, (0, s))
		while len(que) != 0:
			(cost, v) = heapq.heappop(que)
			if d[v] < cost:
				continue
			for i in range(len(self.G[v])):
				e = self.G[v][i]
				if d[e.to] > d[v] + e.cost:
					d[e.to] = d[v] + e.cost
					heapq.heappush(que, (d[e.to], e.to))
		return d

def Z_algorithm(s):
	N = len(s)
	Z_alg = [0] * N
	Z_alg[0] = N
	i = 1
	j = 0
	while i < N:
		while i + j < N and s[j] == s[i + j]:
			j += 1
		Z_alg[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < N and k + Z_alg[k] < j:
			Z_alg[i + k] = Z_alg[k]
			k += 1
		i += k
		j -= k
	return Z_alg

class BIT:

	def __init__(self, n, mod=0):
		self.BIT = [0] * (n + 1)
		self.num = n
		self.mod = mod

	def query(self, idx):
		res_sum = 0
		mod = self.mod
		while idx > 0:
			res_sum += self.BIT[idx]
			if mod:
				res_sum %= mod
			idx -= idx & -idx
		return res_sum

	def update(self, idx, x):
		mod = self.mod
		while idx <= self.num:
			self.BIT[idx] += x
			if mod:
				self.BIT[idx] %= mod
			idx += idx & -idx
		return

class dancinglink:

	def __init__(self, n, debug=False):
		self.n = n
		self.debug = debug
		self._left = [i - 1 for i in range(n)]
		self._right = [i + 1 for i in range(n)]
		self.exist = [True for i in range(n)]

	def pop(self, k):
		if self.debug:
			assert self.exist[k]
		L = self._left[k]
		R = self._right[k]
		if L != -1:
			if R != self.n:
				(self._right[L], self._left[R]) = (R, L)
			else:
				self._right[L] = self.n
		elif R != self.n:
			self._left[R] = -1
		self.exist[k] = False

	def left(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._left[res]
			if res == -1:
				break
			k -= 1
		return res

	def right(self, idx, k=1):
		if self.debug:
			assert self.exist[idx]
		res = idx
		while k:
			res = self._right[res]
			if res == self.n:
				break
			k -= 1
		return res

class SparseTable:

	def __init__(self, A, merge_func, ide_ele):
		N = len(A)
		n = N.bit_length()
		self.table = [[ide_ele for i in range(n)] for i in range(N)]
		self.merge_func = merge_func
		for i in range(N):
			self.table[i][0] = A[i]
		for j in range(1, n):
			for i in range(0, N - 2 ** j + 1):
				f = self.table[i][j - 1]
				s = self.table[i + 2 ** (j - 1)][j - 1]
				self.table[i][j] = self.merge_func(f, s)

	def query(self, s, t):
		b = t - s + 1
		m = b.bit_length() - 1
		return self.merge_func(self.table[s][m], self.table[t - 2 ** m + 1][m])

class BinaryTrie:

	class node:

		def __init__(self, val):
			self.left = None
			self.right = None
			self.max = val

	def __init__(self):
		self.root = self.node(-10 ** 15)

	def append(self, key, val):
		pos = self.root
		for i in range(29, -1, -1):
			pos.max = max(pos.max, val)
			if key >> i & 1:
				if pos.right is None:
					pos.right = self.node(val)
					pos = pos.right
				else:
					pos = pos.right
			elif pos.left is None:
				pos.left = self.node(val)
				pos = pos.left
			else:
				pos = pos.left
		pos.max = max(pos.max, val)

	def search(self, M, xor):
		res = -10 ** 15
		pos = self.root
		for i in range(29, -1, -1):
			if pos is None:
				break
			if M >> i & 1:
				if xor >> i & 1:
					if pos.right:
						res = max(res, pos.right.max)
					pos = pos.left
				else:
					if pos.left:
						res = max(res, pos.left.max)
					pos = pos.right
			elif xor >> i & 1:
				pos = pos.right
			else:
				pos = pos.left
		if pos:
			res = max(res, pos.max)
		return res

def solveequation(edge, ans, n, m):
	x = [0] * m
	used = [False] * n
	for v in range(n):
		if used[v]:
			continue
		y = dfs(v)
		if y != 0:
			return False
	return x

	def dfs(v):
		used[v] = True
		r = ans[v]
		for (to, dire, id) in edge[v]:
			if used[to]:
				continue
			y = dfs(to)
			if dire == -1:
				x[id] = y
			else:
				x[id] = -y
			r += y
		return r

class SegmentTree:

	def __init__(self, init_val, segfunc, ide_ele):
		n = len(init_val)
		self.segfunc = segfunc
		self.ide_ele = ide_ele
		self.num = 1 << (n - 1).bit_length()
		self.tree = [ide_ele] * 2 * self.num
		self.size = n
		for i in range(n):
			self.tree[self.num + i] = init_val[i]
		for i in range(self.num - 1, 0, -1):
			self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

	def update(self, k, x):
		k += self.num
		self.tree[k] = x
		while k > 1:
			self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
			k >>= 1

	def query(self, l, r):
		if r == self.size:
			r = self.num
		res = self.ide_ele
		l += self.num
		r += self.num
		while l < r:
			if l & 1:
				res = self.segfunc(res, self.tree[l])
				l += 1
			if r & 1:
				res = self.segfunc(res, self.tree[r - 1])
			l >>= 1
			r >>= 1
		return res

	def bisect_l(self, l, r, x):
		l += self.num
		r += self.num
		Lmin = -1
		Rmin = -1
		while l < r:
			if l & 1:
				if self.tree[l] <= x and Lmin == -1:
					Lmin = l
				l += 1
			if r & 1:
				if self.tree[r - 1] <= x:
					Rmin = r - 1
			l >>= 1
			r >>= 1
		if Lmin != -1:
			pos = Lmin
			while pos < self.num:
				if self.tree[2 * pos] <= x:
					pos = 2 * pos
				else:
					pos = 2 * pos + 1
			return pos - self.num
		elif Rmin != -1:
			pos = Rmin
			while pos < self.num:
				if self.tree[2 * pos] <= x:
					pos = 2 * pos
				else:
					pos = 2 * pos + 1
			return pos - self.num
		else:
			return -1
import sys, random, bisect
from collections import deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import permutations
from math import gcd, log
input = lambda : sys.stdin.readline().rstrip()
mi = lambda : map(int, input().split())
li = lambda : list(mi())
memo = {}

def solve(n, up):
	if (n, up) in memo:
		return memo[n, up]
	if n == 0:
		if up == 0:
			return 1
		else:
			return 0
	res = 0
	g = up % 10
	for a in range(10):
		b = (n % 10 - a - g) % 10
		if a + b + g >= 10:
			res += solve(n // 10, up // 10 + 10)
		else:
			res += solve(n // 10, up // 10)
	memo[n, up] = res
	return res
for _ in range(int(input())):
	n = int(input())
	print(solve(n, 0) - 2)


from collections import defaultdict, Counter, deque
from math import sqrt, log10, log, floor, factorial, gcd
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations
import sys, io, os
input = sys.stdin.readline
inf = float('inf')
mod = 10 ** 9 + 7

def yn(a):
	print('YES' if a else 'NO')
ceil = lambda a, b: (a + b - 1) // b
t = int(input())
for i in range(t):
	s = input().strip()
	n = len(s)
	a = [s[i] for i in range(0, n, 2)]
	b = [s[i] for i in range(1, n, 2)]
	aint = int('0' + ''.join(a))
	bint = int('0' + ''.join(b))
	if aint == 0:
		print(bint - 1)
	elif bint == 0:
		print(aint - 1)
	else:
		print((aint + 1) * (bint + 1) - 2)


for _ in range(int(input())):
	s = input()
	s1 = ''
	s2 = ''
	for i in range(len(s)):
		if i % 2 == 0:
			s1 += s[i]
		else:
			s2 += s[i]
	if s2 == '':
		print(int(s1) - 1)
	else:
		(s1, s2) = (int(s1) + 1, int(s2) + 1)
		print(s1 * s2 - 2)


t = int(input())
for _ in range(t):
	s = list(map(int, list(input())))
	q = [(0, 1, [])]
	result = 0
	while q:
		(pos, pairs_count, ones_pos) = q.pop(0)
		if pairs_count == 0:
			continue
		add = int(pos in ones_pos)
		if pos == len(s):
			result += pairs_count
			continue
		target = s[-pos - 1] - add
		target = target if target >= 0 else 10 + target
		if target <= 8 and pos + 2 < len(s):
			p = 9 - target
			q.append((pos + 1, pairs_count * p, ones_pos + [pos + 2]))
		if target == 9 and add:
			if pos + 2 < len(s):
				q.append((pos + 1, pairs_count * (target + 1), ones_pos + [pos + 2]))
		else:
			p = target + 1
			q.append((pos + 1, pairs_count * p, ones_pos))
	print(result - 2)


def solve():
	nn = input()
	n1 = '0'
	n2 = '0'
	for i in range(len(nn)):
		if i % 2 == 0:
			n1 += nn[i]
		else:
			n2 += nn[i]
	n1 = int(n1)
	n2 = int(n2)
	print((n1 + 1) * (n2 + 1) - 2)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = input()
	j = 0
	odd = ''
	eve = ''
	for i in reversed(range(len(n))):
		if j % 2 == 0:
			odd = n[i] + odd
		else:
			eve = n[i] + eve
		j += 1
	if len(eve) == 0:
		eve = '0'
	if len(odd) == 0:
		odd = '0'
	print((int(odd) + 1) * (int(eve) + 1) - 2)


a = {-1: 0, 0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 7, 7: 8, 8: 9, 9: 10, 10: 9, 11: 8, 12: 7, 13: 6, 14: 5, 15: 4, 16: 3, 17: 2, 18: 1, 19: 0}

def f(n, s):
	r = 1
	for i in range(len(s) - 1, -1, -1):
		(n, c) = divmod(n, 10)
		if s[i] == 1:
			c -= 1
		if i > 1:
			if s[i - 2] == 1:
				c += 10
		r *= a[c]
	return r
for _ in range(int(input())):
	n = int(input())
	ans = 0
	if len(str(n)) < 3:
		ans = f(n, '0' * len(str(n)))
	else:
		for mask in range(2 ** (len(str(n)) - 2)):
			m = list(map(int, bin(mask)[2:].zfill(len(str(n)) - 2)))
			while len(m) < len(str(n)):
				m.append(0)
			ans += f(n, m)
	print(ans - 2)


ans = []
for _ in range(int(input())):
	s = list(map(int, list(input())))
	n = len(s)
	cnt = 0
	for msk in range(max(1, 2 ** (n - 2))):
		x = [0] * n
		for j in range(n - 2):
			if msk & 2 ** j > 0:
				x[j] = 1
		p = [0] * n
		for j in range(n):
			sm = s[j]
			if j > 1 and x[j - 2] == 1:
				sm += 10
			if x[j] > sm:
				continue
			sm -= x[j]
			if sm > 9:
				p[j] = 9 - (sm - 9) + 1
			else:
				p[j] = sm + 1
		for j in range(1, n):
			p[j] *= p[j - 1]
		cnt += p[-1]
	ans.append(cnt - 2)
print('\n'.join(map(str, ans)))


import sys
input = sys.stdin.readline

def solve():
	s = '0' + input().strip()
	a = int(s[0::2])
	b = int(s[1::2])
	return (a + 1) * (b + 1) - 2
for _ in range(int(input())):
	print(solve())


from collections import defaultdict as dd
import math
import sys
input = sys.stdin.readline

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return map(int, input().split())

def lm():
	return list(map(int, input().split()))

def solve():
	n = input()
	evens = 0
	odds = 0
	if int(n[:-1]) < 10:
		print(int(n[:-1]) - 1)
		return
	for i in reversed(range(len(n) - 1)):
		if (len(n) - 2 - i) % 2 == 0:
			evens += int(n[i]) * 10 ** ((len(n) - 2 - i) // 2)
		else:
			odds += int(n[i]) * 10 ** ((len(n) - 2 - i) // 2)
	sub = (evens + 1) * (odds + 1)
	sub -= 2
	print(sub)
q = nn()
for _ in range(q):
	solve()


import collections
import math
import itertools
import sys
import time

def fast_input():
	return sys.stdin.readline().strip()
input = fast_input

def ints_input():
	return list((int(x) for x in input().split()))

def int_input():
	return int(input())

def solve():
	a = input()
	digits = [int(c) for c in a]
	all_ways = 0
	if len(digits) <= 2:
		ways = 1
		for x in digits:
			if x < 0 or x > 18:
				ways *= 0
			elif x <= 9:
				ways *= x + 1
			else:
				ways *= 19 - x
		print(ways - 2)
	else:
		for carried in range(0, 2 ** (len(digits) - 2)):
			copy = list(digits)
			for i in range(len(digits) - 2):
				if carried & 2 ** i:
					copy[i + 2] += 10
					copy[i] -= 1
			ways = 1
			for x in copy:
				if x < 0 or x > 18:
					ways *= 0
				elif x <= 9:
					ways *= x + 1
				else:
					ways *= 19 - x
			all_ways += ways
		print(all_ways - 2)
if True:
	for _ in range(int_input()):
		solve()
else:
	solve()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = input()[:-1]
	a = int(n[::2] or 0)
	b = int(n[1::2] or 0)
	print((a + 1) * (b + 1) - 2)


from __future__ import print_function
from math import *
from collections import deque
import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	l = insr()
	xx = int(''.join((i for i in l)))
	if xx < 10:
		print(xx - 1)
		continue
	l = list(map(int, l))
	n = len(l)
	l.reverse()
	c = 0
	carry = [0] * n
	for i in range(int(2 ** (n - 2))):
		tmp = 1
		for j in range(n):
			req = l[j]
			if i >> j & 1 == 0:
				if carry[j] and req == 0:
					tmp = 0
				if carry[j]:
					req -= 1
				tmp = tmp * (req + 1)
			else:
				carry[j + 2] = 1
				if req == 0 and carry[j]:
					tmp = tmp * 10
					continue
				if carry[j]:
					req -= 1
				x = 9
				y = req + 10 - x
				tt = x - y + 1
				tmp = tmp * tt
		c += tmp
		carry = [0] * n
	print(c - 2)


t = int(input())
for aslkdjaskdj in range(t):
	n = input()
	flag = 0
	j = '0'
	o = '0'
	for i in n:
		if flag == 0:
			o += i
		else:
			j += i
		flag = 1 - flag
	j = int(j)
	o = int(o)
	print((j + 1) * (o + 1) - 2)


def main():
	alpha = 'abcdefghijklmnopqrstuvwxyz'
	ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	inf = 1e+17
	mod = 10 ** 9 + 7

	def factorial(n):
		f = 1
		for i in range(1, n + 1):
			f = f * i % mod
		return f

	def ncr(n, r):
		num = den = 1
		for i in range(r):
			num = num * (n - i) % mod
			den = den * (i + 1) % mod
		return num * pow(den, mod - 2, mod) % mod

	def solve(n):
		str_n = str(n).zfill(2)
		n_odd = ''
		n_even = ''
		for i in range(len(str_n)):
			if i % 2:
				n_odd += str_n[i]
			else:
				n_even += str_n[i]
		return max(int(n_odd) + 1, 1) * max(int(n_even) + 1, 1) - 2
	t = int(input())
	ans = []
	for _ in range(t):
		n = int(input())
		ans.append(solve(n))
	for a in ans:
		print(a)
import sys, threading
import bisect
import math
import itertools
from sys import stdout
import heapq
from queue import PriorityQueue
input = sys.stdin.readline
thread = threading.Thread(target=main)
thread.start()
thread.join()


T = int(input())
for t in range(T):
	N = input()
	num1 = ''
	for i in range(0, len(N), 2):
		num1 = num1 + N[i]
	num1 = int(num1)
	num2 = ''
	for i in range(1, len(N), 2):
		num2 = num2 + N[i]
	if num2 == '':
		print(num1 - 1)
	else:
		num2 = int(num2)
		print((num1 + 1) * (num2 + 1) - 2)


from collections import defaultdict, Counter, deque
from math import sqrt, log10, log, floor, factorial, gcd
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations
import sys, io, os
input = sys.stdin.readline
inf = float('inf')
mod = 10 ** 9 + 7

def yn(a):
	print('YES' if a else 'NO')
ceil = lambda a, b: (a + b - 1) // b
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	s = input().strip()
	n = len(s)
	a = [s[i] for i in range(0, n, 2)]
	b = [s[i] for i in range(1, n, 2)]
	aint = int(''.join(a)) if a else 0
	bint = int(''.join(b)) if b else 0
	if aint == 0 or bint == 0:
		print(max(bint - 1, aint - 1))
	else:
		print((aint + 1) * (bint + 1) - 2)


def cal():
	s = list(input())
	first = int(''.join(s[0::2])) + 1
	second = int(''.join(s[1::2])) + 1 if len(s) > 1 else 1
	print(first * second - 2)

def main():
	t = int(input())
	while t:
		cal()
		t -= 1
main()


def solve(n):
	a = 0
	b = 0
	s = str(n)
	for i in range(len(s)):
		if i % 2 == 0:
			a = a * 10 + int(s[i])
		else:
			b = b * 10 + int(s[i])
	return (a + 1) * (b + 1) - 2
t = int(input())
for _ in range(t):
	n = int(input())
	print(solve(n))


t = int(input())
while t > 0:
	t -= 1
	s = input().strip()
	(a, b) = ('', '')
	for i in range(len(s)):
		if i % 2 == 0:
			a += s[i]
		else:
			b += s[i]
	if b == '':
		b = 0
	else:
		b = int(b)
	a = int(a)
	print((a + 1) * (b + 1) - 2)


for _ in range(int(input())):
	a = input()
	x = 0
	y = 0
	for i in range(len(a)):
		if i & 1:
			x = x * 10 + int(a[i])
		else:
			y = y * 10 + int(a[i])
	print((x + 1) * (y + 1) - 2)


import functools
import sys
input = iter(sys.stdin.read().splitlines()).__next__

def solve():
	n = int(input())
	digits = []
	while n:
		(n, digit) = divmod(n, 10)
		digits.append(digit)
	num_digits = len(digits)
	if len(digits) == 1:
		return digits[0] - 1
	count = -2
	for i in range(1 << num_digits - 2):
		digits_with_carry = [i >> j & 1 for j in range(num_digits)]
		original_digit_sums = []
		for j in range(num_digits):
			carried_here = digits_with_carry[j - 2] if j >= 2 else 0
			original_digit_sums.append(digits_with_carry[j] * 10 + digits[j] - carried_here)
		if -1 in original_digit_sums:
			continue
		count_per_digit = [min(digit_sum + 1, 9 - (digit_sum - 9) + 1) for digit_sum in original_digit_sums]
		count += functools.reduce(lambda x, y: x * y, count_per_digit)
	return count
t = int(input())
output = []
for _ in range(t):
	output.append(solve())
print(*output, sep='\n')


def helper(x):
	l = []
	while x > 0:
		l.append(x % 10)
		x = x // 10
	l.reverse()
	xe = 0
	xo = 0
	for i in range(len(l)):
		if i % 2 == 0:
			xe = 10 * xe + l[i]
		else:
			xo = 10 * xo + l[i]
	return (xo + 1) * (xe + 1) - 2
t = int(input())
for xx in range(t):
	n = int(input())
	print(helper(n))


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def msi():
	return map(str, input().split())

def li():
	return list(mi())
t = ii()
for _ in range(t):
	n = si()
	a = int('0' + ''.join([n[i] for i in range(0, len(n), 2)]))
	b = int('0' + ''.join([n[i] for i in range(1, len(n), 2)]))
	print((a + 1) * (b + 1) - 2)


import sys
from collections import defaultdict as dd
input = sys.stdin.readline
dec2 = dd(int)
for i in range(0, 10):
	for j in range(0, 10):
		dec2[i + j] += 1

def solve(i, r):
	if i == m - 1:
		ans = dec2[r[-1]]
		return ans
	ans = 0
	ans += solve(i + 1, r) * dec2[r[i]]
	if i <= m - 3:
		r[i + 2] += 10
		ans += solve(i + 1, r) * dec2[r[i] - 1]
		r[i + 2] -= 10
	return ans
for _ in range(int(input())):
	n = input()
	r = []
	dec = '0123456789'
	for i in n:
		if i in dec:
			r.append(int(i))
	m = len(r)
	print(solve(0, r) - 2)


import sys
import math

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def get_int():
	return int(sys.stdin.readline().strip())

def get_list_strings():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve(n):
	if n < 10:
		sys.stdout.write(str(n - 1) + '\n')
		return
	num1 = ''
	num2 = ''
	n = str(n)
	l = len(n)
	for i in range(l):
		if i % 2 == 0:
			num1 += str(n[i])
		else:
			num2 += str(n[i])
	num1 = int(num1)
	num2 = int(num2)
	ans = (num1 + 1) * (num2 + 1) - 2
	sys.stdout.write(str(ans) + '\n')
	return
T = get_int()
while T:
	n = get_int()
	solve(n)
	T -= 1


import sys
import os
import math
from io import BytesIO, IOBase
from collections import defaultdict, Counter, deque
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	n = input()
	first = 0
	sec = 0
	for j in range(len(n)):
		if j % 2 == 0:
			first = first * 10 + int(n[j])
		else:
			sec = sec * 10 + int(n[j])
	first += 1
	sec += 1
	print(first * sec - 2)


from sys import stdin
input = stdin.readline

def func(b, k):
	if b >= k:
		v = 1
		flag = 0
		t = a.copy()
		for x in range(k - 1, -1, -1):
			if o[x] == 0:
				if t[x] < 0:
					v = 0
					break
				v = v * (t[x] + 1)
			else:
				flag = 1
				l = t[x] + 1
				r = 9
				if l <= r:
					v = v * (r - l + 1)
					if x >= 2:
						t[x - 2] -= 1
				else:
					v = 0
					break
		if flag == 0:
			v -= 2
		res[-1] += v
		return
	o[b] = 0
	func(b + 1, k)
	o[b] = 1
	func(b + 1, k)
for _ in range(int(input())):
	n = input().rstrip()
	a = list(map(int, n))
	n = len(n)
	k = len(a)
	o = [0] * 21
	res = [0]
	func(2, k)
	print(res[-1])


from math import *
from collections import *
from functools import *
from bisect import *
from itertools import *
from heapq import *
from statistics import *
inf = float('inf')
ninf = -float('inf')
ip = input
alphal = 'abcdefghijklmnopqrstuvwxyz'
alphau = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def ipl():
	return list(map(int, ip().split()))

def ipn():
	return int(ip())

def ipf():
	return float(ip())

def solve():
	n = ip()
	print(((int(n[0::2]) if n[0::2] else 0) + 1) * ((int(n[1::2]) if n[1::2] else 0) + 1) - 2)
t = ipn()
for _ in range(t):
	solve()


numOfTestCases = int(input())
while numOfTestCases > 0:
	numOfTestCases -= 1
	aliceResult = input()
	oddnumber = '0'
	evenNumber = '0'
	for (i, c) in enumerate(aliceResult):
		if i % 2 == 0:
			evenNumber += c
		else:
			oddnumber += c
	oddnumber = int(oddnumber)
	evenNumber = int(evenNumber)
	print((oddnumber + 1) * (evenNumber + 1) - 2)


import math

def solve():
	n = int(input())
	D = int(math.log(n, 10)) + 1
	N = list(map(int, str(n)))[::-1]
	ways = 0
	for d in range(1 if D <= 2 else 1 << D - 2):
		carry = [0] * D
		ways_for_d = 1
		digits = []
		for p in range(D):
			digit = []
			target_digit = N[p]
			creates_carry_here = d >> p & 1
			if creates_carry_here:
				carry[p + 2] = 1
			ways_for_p = 0
			for a in range(10):
				for b in range(10):
					target_sum = target_digit + creates_carry_here * 10
					if target_sum == a + b + carry[p]:
						ways_for_p += 1
						digit.append((a, b))
			ways_for_d *= ways_for_p
			digits.append(digit)
			if ways_for_d == 0:
				digits = []
				break
		ways += ways_for_d
	print(ways - 2)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


import math
import sys
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

def nextPowerOf2(n):
	p = 1
	if n and (not n & n - 1):
		return n
	while p < n:
		p <<= 1
	return p

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

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

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

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

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

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)
main()


def solve(n):
	a = b = 0
	place = 1
	while n:
		a += n % 10 * place
		n //= 10
		b += n % 10 * place
		n //= 10
		place *= 10
	return (a + 1) * (b + 1) - 2
for t in range(int(input())):
	n = int(input())
	print(solve(n))


t = int(input())
for _ in range(t):
	n = input()
	(l1, l2) = ('', '')
	for i in range(0, len(n)):
		if i % 2 == 0:
			l1 += n[i]
		else:
			l2 += n[i]
	if len(l1) > 0:
		l1 = int(l1)
	else:
		l1 = 0
	if len(l2) > 0:
		l2 = int(l2)
	else:
		l2 = 0
	print((l1 + 1) * (l2 + 1) - 2)


for _ in range(int(input())):
	n = ['0'] + list(input())
	evens = int(''.join([i for i in n[::2]]))
	odds = int(''.join([i for i in n[1::2]]))
	print((evens + 1) * (odds + 1) - 2)


t = int(input())
for case in range(t):
	n = input()
	a = int(n[0::2]) + 1
	b = int(n[1::2] or '0') + 1
	print(a * b - 2)


T = int(input())
for i in range(T):
	k = input()
	t = len(k)
	s = ''
	r = ''
	for i in range(t - 1, -1, -1):
		if i % 2 == 0:
			s = k[i] + s
		else:
			r = k[i] + r
	s = '0' + s
	r = '0' + r
	print((int(s) + 1) * (int(r) + 1) - 2)


def solve():
	n = str(input())
	a = ''
	b = ''
	if len(n) == 1:
		a = int(n)
		b = 0
	else:
		for i in range(len(n)):
			if i % 2 == 0:
				a = a + n[i]
			else:
				b = b + n[i]
		a = int(a)
		b = int(b)
	result = (a + 1) * (b + 1) - 2
	print(result)
t = int(input())
for i in range(t):
	solve()


d1 = {}
d2 = {9: 0}
for i in range(10):
	for j in range(10):
		if i + j < 10:
			if i + j not in d1:
				d1[i + j] = 0
			d1[i + j] += 1
		else:
			i1 = (i + j) % 10
			if i1 not in d2:
				d2[i1] = 0
			d2[i1] += 1
f_dict = {0: 1}

def process(n):
	if n < 0:
		return 0
	if n in f_dict:
		return f_dict[n]
	answer = 0
	n1 = n % 10
	n2 = n // 10
	answer = process(n // 10) * d1[n1]
	if n2 >= 10:
		n3 = list(str(n2))
		m = len(n3)
		works = False
		while m - 2 >= 0:
			if n3[m - 2] == '0':
				n3[m - 2] = '9'
			else:
				n3[m - 2] = str(int(n3[m - 2]) - 1)
				works = True
				break
			m -= 2
		if works:
			n3 = int(''.join(n3))
			answer += process(n3) * d2[n1]
	f_dict[n] = answer
	return answer
t = int(input())
for i in range(t):
	n = int(input())
	answer = process(n)
	print(answer - 2)


for _ in range(int(input())):
	n = input()
	a = int('0' + ''.join([n[i] for i in range(len(n)) if i % 2 == 0]))
	b = int('0' + ''.join([n[i] for i in range(len(n)) if i % 2 != 0]))
	print((a + 1) * (b + 1) - 2)


def div_num(N):
	num = str(N)
	n1 = num[::2]
	n2 = num[1::2]
	return (int(n1), int(n2))
for i in range(int(input())):
	n = int(input())
	if n < 10:
		ans = n - 1
	else:
		(num1, num2) = div_num(n)
		ans = (num1 + 1) * (num2 + 1) - 2
	print(ans)


for _ in range(int(input())):
	n = input()
	flag = True
	i = 0
	a = ''
	b = ''
	while i < len(n):
		if flag == True:
			a += n[i]
			i += 1
			flag = False
		else:
			b += n[i]
			i += 1
			flag = True
	a = int(a) if a != '' else 0
	b = int(b) if b != '' else 0
	print((a + 1) * (b + 1) - 2)


def int_input():
	a = int(input())
	return a

def int_list_input():
	a = list(map(int, input().split()))
	return a

def solve():
	n = input()
	a = ''
	b = ''
	for i in range(0, len(n), 2):
		a += n[i]
	for i in range(1, len(n), 2):
		b += n[i]
	ans = int(a) + 1
	if b != '':
		ans = ans * (int(b) + 1)
	print(ans - 2)
for _ in range(int(input())):
	solve()


import os, sys
from io import BytesIO, IOBase

def rec(a, i):
	if i == len(a):
		return 1
	if i < len(a) - 2:
		x = a[:]
		x[i + 2] += 10
		if a[i] < 10:
			return (a[i] + 1) * rec(a, i + 1) + a[i] * rec(x, i + 1)
		return (19 - a[i]) * rec(a, i + 1) + (20 - a[i]) * rec(x, i + 1)
	if a[i] < 10:
		return (a[i] + 1) * rec(a, i + 1)
	return (19 - a[i]) * rec(a, i + 1)

def main():
	for _ in range(int(input())):
		x = int(input())
		a = []
		while x:
			a.append(x % 10)
			x //= 10
		a.reverse()
		print(rec(a, 0) - 2)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


tc = int(input())
for _ in range(tc):
	n = input().strip()
	n = n[::-1]
	a = ''
	b = ''
	for i in range(len(n)):
		if i % 2 == 0:
			a = n[i] + a
		else:
			b = n[i] + b
	if a == '':
		a = 0
	else:
		a = int(a)
	if b == '':
		b = 0
	else:
		b = int(b)
	ans = (a + 1) * (b + 1) - 2
	print(ans)


t = int(input())
for i in range(t):
	n = input()
	o = ''
	e = ''
	k = 1
	for j in range(0, len(n)):
		if k & 1:
			o = o + n[j]
		else:
			e = e + n[j]
		k += 1
	if len(o) > 0:
		o = int(o)
	else:
		o = 0
	if len(e) > 0:
		e = int(e)
	else:
		e = 0
	if o == 0:
		print(e - 1)
	elif e == 0:
		print(o - 1)
	else:
		print((o + 1) * (e + 1) - 2)


from math import log10, ceil

def get_digit(number, place):
	return number // 10 ** place % 10

def solve():
	n = int(input())
	order = ceil(log10(n))
	(a, b) = (0, 0)
	for place in range(order + 1):
		to_add = 10 ** (place // 2) * get_digit(n, place)
		if place % 2 == 0:
			a += to_add
		else:
			b += to_add
	return (a + 1) * (b + 1) - 2

def main():
	num_tests = int(input())
	for t in range(1, num_tests + 1):
		print(solve())
main()


from sys import stdin, stdout
nmbr = lambda : int(input())
lst = lambda : list(map(int, input().split()))
for _ in range(nmbr()):
	s = input()
	n = len(s)
	even = 0
	odd = 0
	for i in range(n):
		if i & 1 == 0:
			even = even * 10 + int(s[i])
		else:
			odd = odd * 10 + int(s[i])
	ans = (even + 1) * (odd + 1) - 2
	print(ans)


import bisect
import heapq
import math
import collections
import sys
import copy
from functools import reduce
import decimal
from io import BytesIO, IOBase
import os
import itertools
import functools
from types import GeneratorType
sys.setrecursionlimit(10 ** 9)
decimal.getcontext().rounding = decimal.ROUND_HALF_UP
graphDict = collections.defaultdict
queue = collections.deque

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		to = f(*args, **kwargs)
		if stack:
			return to
		else:
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						return to
					to = stack[-1].send(to)
	return wrappedfunc

class Graphs:

	def __init__(self):
		self.graph = graphDict(set)

	def add_edge(self, u, v):
		self.graph[u].add(v)
		self.graph[v].add(u)

	def dfs_utility(self, nodes, visited_nodes):
		visited_nodes.add(nodes)
		for neighbour in self.graph[nodes]:
			if neighbour not in visited_nodes:
				self.dfs_utility(neighbour, visited_nodes)

	def dfs(self, node):
		Visited = set()
		self.dfs_utility(i, Visited)

	def bfs(self, node, f_node):
		count = float('inf')
		visited = set()
		level = 0
		if node not in visited:
			queue.append([node, level])
			visited.add(node)
		flag = 0
		while queue:
			parent = queue.popleft()
			if parent[0] == f_node:
				flag = 1
				count = min(count, parent[1])
			level = parent[1] + 1
			for item in self.graph[parent[0]]:
				if item not in visited:
					queue.append([item, level])
					visited.add(item)
		return count if flag else -1

class Tree:

	def __init__(self, data):
		self.data = data
		self.left = None
		self.right = None

def inorder(node, lis):
	if node:
		inorder(node.left, lis)
		lis.append(node.data)
		inorder(node.right, lis)
	return lis

def leaf_node_sum(root):
	if root is None:
		return 0
	if root.left is None and root.right is None:
		return root.data
	return leaf_node_sum(root.left) + leaf_node_sum(root.right)

def hight(root):
	if root is None:
		return -1
	if root.left is None and root.right is None:
		return 0
	return max(hight(root.left), hight(root.right)) + 1

class UF:

	def __init__(self, N):
		self._id = list(range(N))
		self._count = N
		self._rank = [0] * N

	def find(self, p):
		id = self._id
		while p != id[p]:
			p = id[p] = id[id[p]]
		return p

	def count(self):
		return self._count

	def connected(self, p, q):
		return self.find(p) == self.find(q)

	def union(self, p, q):
		id = self._id
		rank = self._rank
		i = self.find(p)
		j = self.find(q)
		if i == j:
			return
		self._count -= 1
		if rank[i] < rank[j]:
			id[i] = j
		elif rank[i] > rank[j]:
			id[j] = i
		else:
			id[j] = i
			rank[i] += 1

	def __str__(self):
		return ' '.join([str(x) for x in self._id])

	def __repr__(self):
		return 'UF(' + str(self) + ')'

def rounding(n):
	return int(decimal.Decimal(f'{n}').to_integral_value())

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0), []))

def p_sum(array):
	return list(itertools.accumulate(array))

def diophantine(a: int, b: int, c: int):
	(d, x, y) = extended_gcd(a, b)
	r = c // d
	return (r * x, r * y)

@bootstrap
def extended_gcd(a: int, b: int):
	if b == 0:
		(d, x, y) = (a, 1, 0)
	else:
		(d, p, q) = (yield extended_gcd(b, a % b))
		x = q
		y = p - q * (a // b)
	yield (d, x, y)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, **kwargs):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def inp():
	return sys.stdin.readline().strip()

def map_inp(v_type):
	return map(v_type, inp().split())

def list_inp(v_type):
	return list(map_inp(v_type))
for _ in range(int(inp())):
	n = inp()
	even = ['0']
	odd = ['0']
	for i in range(len(n)):
		if i & 1:
			even.append(n[i])
		else:
			odd.append(n[i])
	print((int(''.join(even)) + 1) * (int(''.join(odd)) + 1) - 2)


n = int(input())
for i in range(n):
	r = input()
	if len(r) == 1:
		print(int(r) - 1)
	else:
		a = int(r[::2])
		b = int(r[1::2])
		print((a + 1) * (b + 1) - 2)


import sys
import math
from bisect import bisect_right as br
from itertools import combinations as cb

def int_arr():
	return list(map(int, sys.stdin.readline().strip().split()))

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = input()
	even = '0'
	odd = '0'
	for i in range(len(n)):
		if i % 2 == 0:
			even += n[i]
		else:
			odd += n[i]
	print((int(even) + 1) * (int(odd) + 1) - 2)


T = int(input())
for _ in range(T):
	s = '0' + input()
	(s1, s2) = (int(s[::2]), int(s[1::2]))
	print((s1 + 1) * (s2 + 1) - 2)


import sys
input = sys.stdin.readline
t = int(input())
pow2 = [1]
for _ in range(12):
	pow2.append(2 * pow2[-1])
c = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0]
for _ in range(t):
	n = list(input().rstrip())
	n.reverse()
	for i in range(len(n)):
		n[i] = int(n[i])
	l = len(n) - 2
	if l <= 0:
		ans = 1
		for i in n:
			ans *= i + 1
		ans -= 2
	else:
		ans = 0
		for i in range(pow2[l]):
			ok = 1
			n0 = list(n)
			for j in range(l):
				if pow2[j] & i:
					n0[j] += 10
					n0[j + 2] -= 1
			if min(n0) < 0:
				continue
			cnt = 1
			for j in n0:
				cnt *= c[j]
			ans += cnt
		ans -= 2
	print(ans)


t = int(input())
for iter in range(t):
	c = list(input())
	c.reverse()
	c = ''.join(c)
	s = c
	a0 = dict()
	a0[-1] = 0
	a0[0] = 1
	a0[1] = 2
	a0[2] = 3
	a0[3] = 4
	a0[4] = 5
	a0[5] = 6
	a0[6] = 7
	a0[7] = 8
	a0[8] = 9
	a0[9] = 10
	a1 = dict()
	a1[-1] = 10
	a1[0] = 9
	a1[1] = 8
	a1[2] = 7
	a1[3] = 6
	a1[4] = 5
	a1[5] = 4
	a1[6] = 3
	a1[7] = 2
	a1[8] = 1
	a1[9] = 0
	a00 = dict()
	a00[-1] = 0
	a00[0] = 0
	a00[1] = 2
	a00[2] = 3
	a00[3] = 4
	a00[4] = 5
	a00[5] = 6
	a00[6] = 7
	a00[7] = 8
	a00[8] = 9
	a00[9] = 10
	a10 = dict()
	a10[-1] = 10
	a10[0] = 9
	a10[1] = 8
	a10[2] = 7
	a10[3] = 6
	a10[4] = 5
	a10[5] = 4
	a10[6] = 3
	a10[7] = 2
	a10[8] = 1
	a10[9] = 0
	ans = dict()
	ans[-1] = [1, 0, 0, 0]
	for i in range(len(s)):
		local_ans = [0, 0, 0, 0]
		last_ans = ans[i - 1]
		local_ans[0] += last_ans[0] * a0[int(s[i])]
		local_ans[1] += last_ans[0] * a1[int(s[i])]
		local_ans[3] += last_ans[1] * a1[int(s[i])]
		local_ans[2] += last_ans[1] * a0[int(s[i])]
		local_ans[0] += last_ans[2] * a0[int(s[i]) - 1]
		local_ans[1] += last_ans[2] * a1[int(s[i]) - 1]
		local_ans[3] += last_ans[3] * a1[int(s[i]) - 1]
		local_ans[2] += last_ans[3] * a0[int(s[i]) - 1]
		ans[i] = local_ans
	print(ans[len(s) - 1][0] - 2)


import sys
input = sys.stdin.readline

def solve():
	s = input().strip()
	n = len(s)
	even = [0, 0]
	odd = [0, 0]
	if int(s) < 10:
		return int(s) - 1
	s = s[::-1]
	(d0, d1) = (int(s[0]), int(s[1]))
	dp = [[d0 + 1, 9 - d0], [d1 + 1, 9 - d1]]
	for i in range(2, n):
		d = int(s[i])
		dp[i % 2] = [(d + 1) * dp[i % 2][0] + d * dp[i % 2][1], (9 - d) * dp[i % 2][0] + (9 - d + 1) * dp[i % 2][1]]
	return dp[0][0] * dp[1][0] - 2
for _ in range(int(input())):
	print(solve())


for _ in range(int(input())):
	s = input()
	n1 = s[::2]
	n2 = s[1::2]
	s1 = 1
	if n1 != '':
		s1 *= int(n1) + 1
	if n2 != '':
		s1 *= int(n2) + 1
	print(s1 - 2)


t = int(input())
for i in range(t):
	n = input()
	a = 0
	b = 0
	i = 0
	state = False
	for x in range(1, len(n) + 1):
		digit = int(n[-1 * x])
		if state:
			b += 10 ** i * digit
		else:
			a += 10 ** i * digit
		if state:
			i += 1
		state = not state
	ans = (a + 1) * (b + 1) - 2
	print(ans)


def recursion(a, i, prev):
	if i >= 0:
		if i - 2 >= 0:
			if a[i] == 0 and prev == 'carry':
				x = 9
				y = d[x]['normal']
				r1 = recursion(a, i - 2, 'carry')
				ans = r1 * y
				return ans
			else:
				if prev == 'carry':
					x = a[i] - 1
				else:
					x = a[i]
				y = d[x]['normal']
				r1 = recursion(a, i - 2, 'normal')
				ans = r1 * y
				y = d[x]['carry']
				r2 = recursion(a, i - 2, 'carry')
				ans += r2 * y
				return ans
		elif prev == 'carry':
			if a[i] == 0:
				return 0
			else:
				return d[a[i] - 1]['normal']
		else:
			return d[a[i]]['normal']
	else:
		return 1
d = {}
for i in range(10):
	d[i] = {'normal': 1 + i, 'carry': 10 - i - 1}
for _ in range(int(input())):
	a = list(map(int, list(input())))
	n = len(a)
	ans = recursion(a, n - 1, 'normal')
	ans *= recursion(a, n - 2, 'normal')
	print(ans - 2)


n = int(input())
for _ in range(n):
	x = input().zfill(10)
	x1 = int(x[::2]) + 1
	x2 = int(x[1::2]) + 1
	print(x1 * x2 - 2)
exit()


n = int(input())

def get_n(n):
	s = str(n)
	res_c = ''
	res_n = ''
	for j in range(len(str(n))):
		if j % 2 == 0:
			res_n += s[j]
		else:
			res_c += s[j]
	res_c = int(res_c) + 1
	res_n = int(res_n) + 1
	return (res_c, res_n)

def get_res(number):
	if number < 10:
		return number - 1
	(n, m) = get_n(number)
	t = n
	n = m
	m = t
	if n == 1 or m == 1:
		return n - 2
	else:
		return n * (m - 2) + (n - 1) * 2
res = []
for i in range(n):
	res.append(get_res(int(input())))
for elem in res:
	print(elem)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections, string, bisect, re, random, queue, itertools, statistics, math
from collections import *
from bisect import *
from string import *
from itertools import *
from statistics import *
from math import *
from re import *
from queue import *

class Stack:

	def __init__(self):
		self.items = []

	def push(self, item):
		self.items.append(item)

	def pop(self):
		return self.items.pop()

	def empty(self):
		return self.items == []

	def size(self):
		return len(self.items)

	def at(self, idx):
		try:
			return self.items[idx]
		except:
			return -1

class priority_queue(object):

	def __init__(self):
		self.queue = []

	def __str__(self):
		return ' '.join([str(i) for i in self.queue])

	def empty(self):
		return len(self.queue) == 0

	def insert(self, data):
		self.queue.append(data)

	def delete(self):
		try:
			max = 0
			for i in range(len(self.queue)):
				if self.queue[i] > self.queue[max]:
					max = i
			item = self.queue[max]
			del self.queue[max]
			return item
		except IndexError:
			print()
			exit()
mod = int(1000000000.0 + 7)
imin = -2147483648
imax = 2147483647
true = True
false = False
N = int(300000.0 + 5)
none = None
inp = lambda : input()
I = lambda : int(inp())
M = lambda : map(int, inp().split())
MS = lambda : map(str, inp().split())
S = lambda : list(MS())
L = lambda : list(M())
Yes = lambda : print('Yes')
No = lambda : print('No')
YES = lambda : print('YES')
NO = lambda : print('NO')
yes = lambda : print('yes')
no = lambda : print('no')
chartonum = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '0': 0}

def IO():
	try:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('uttar.txt', 'w')
	except:
		pass

def true_yes(statement):
	return YES() if statement else NO()

def binary(x):
	return bin(x).replace('0b', '')

def state(statement, one, two):
	print(one if statement else two)

def swap(a, b):
	(a, b) = (b, a)

def bintodec(n):
	return int(n, 2)

def prec(a):
	return '{0:.9f}'.format(a)

def case(t):
	print('Case #' + str(t) + ': ', end='')

def palin(s):
	return s == s[::-1]

def second(arr):
	return arr[1]

def first(arr):
	return arr[0]

def is_sorted(arr):
	return arr == sorted(arr)
IO()

def kabraji_ka_totka():
	n = inp()
	if int(n) <= 9:
		print(int(n) - 1)
		return
	one = int(n[::2])
	two = int(n[1::2])
	print((one + 1) * (two + 1) - 2)
for i in range(I()):
	kabraji_ka_totka()


from functools import lru_cache
t = int(input())
global l, size
l = list()

@lru_cache(None)
def dp(i=0, carry=0, second_carry=0):
	if i >= size:
		return int(carry == 0 and second_carry == 0)
	t = l[i]
	ways = 0
	for a in range(10):
		for b in range(10):
			s = a + b + carry
			if s % 10 == t:
				new_carry = int(s > 9)
				ways += dp(i + 1, second_carry, new_carry)
	return ways
for _ in range(t):
	n = int(input())
	l = list(str(n))[::-1]
	l = list(map(int, l))
	size = len(l)
	dp.cache_clear()
	ans = dp() - 2
	print(ans)


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
lx = lambda x: map(int, input().split(x))
yy = lambda : print('YES')
nn = lambda : print('NO')
from math import log10, log2, ceil, factorial as fac, gcd, inf, sqrt, log
from bisect import bisect_right as br, bisect_left as bl
from collections import Counter
mod = 10 ** 9 + 7
dp = [0]
for i in range(1, 3 * 10 ** 5 + 1):
	dp.append(dp[i - 1] ^ i)
for _ in range(t()):
	s = ss()
	(p, q) = (0, 0)
	for i in range(len(s)):
		if i % 2 == 0:
			p = p * 10 + int(s[i])
		else:
			q = q * 10 + int(s[i])
	if q == 0:
		print(p - 1)
	else:
		print((p + 1) * (q + 1) - 2)


for _ in range(int(input())):
	n = int(input())
	n1 = 0
	n2 = 0
	idx = 0
	p1 = 0
	p2 = 0
	while n != 0:
		rem = n % 10
		if idx % 2 == 0:
			n1 += rem * pow(10, p1)
			p1 += 1
		else:
			n2 += rem * pow(10, p2)
			p2 += 1
		n = n // 10
		idx += 1
	n1 -= 1
	n2 -= 1
	ans = n2 * n1 + n1 * 2 + n2 * 2 + 2
	print(ans)


import sys
input = sys.stdin.readline

def I():
	return input().strip()

def II():
	return int(input().strip())

def LI():
	return [*map(int, input().strip().split())]
import copy, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter, OrderedDict
from itertools import permutations, chain, combinations, groupby
from operator import itemgetter
from types import GeneratorType
from typing import Iterable, TypeVar, Union

def get(x):
	if not x:
		return 0
	return int(x)
for _ in range(II()):
	n = I()
	(a, b) = ('', '')
	for i in range(len(n)):
		if i % 2:
			a += n[i]
		else:
			b += n[i]
	print((get(a) + 1) * (get(b) + 1) - 2)


t = int(input())
for tt in range(t):
	s = list(input())
	s1 = ''
	s2 = ''
	n = len(s)
	for i in range(0, n, 2):
		s1 += s[i]
	for i in range(1, n, 2):
		s2 += s[i]
	if s1:
		s1 = int(s1)
	else:
		s1 = 0
	if s2:
		s2 = int(s2)
	else:
		s2 = 0
	print((s1 + 1) * (s2 + 1) - 2)


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from time import time
from itertools import permutations as per
from heapq import heapify, heappush, heappop, heappushpop
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\r\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
inv = lambda x: pow(x, N - 2, N)
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	n = S()
	x = 0
	y = 0
	x = int(''.join([n[i] for i in range(0, len(n), 2)]))
	if len(n) > 1:
		y = int(''.join([n[i] for i in range(1, len(n), 2)]))
	print((x + 1) * (y + 1) - 2)


import os, sys
from io import BytesIO, IOBase

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class dict(dict):

	def __missing__(self, key):
		return 0
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda dtype: [dtype(x) for x in input().split()]
inp_2d = lambda dtype, n: [dtype(input()) for _ in range(n)]
inp_2ds = lambda dtype, n: [inp(dtype) for _ in range(n)]
inp_enu = lambda dtype: [(i, x) for (i, x) in enumerate(inp(dtype))]
inp_enus = lambda dtype, n: [[i] + inp(dtype) for i in range(n)]
ceil1 = lambda a, b: (a + b - 1) // b
get_bit = lambda x, i: x >> i & 1
for _ in range(int(input())):
	n = '0' + input()
	(n1, n2) = (int(n[0::2]) + 1, int(n[1::2]) + 1)
	print(n1 * n2 - 2)


def solve():
	s = input()
	f = 0
	a = '0'
	b = '0'
	for c in s:
		if f:
			a += c
		else:
			b += c
		f ^= 1
	print((int(a) + 1) * (int(b) + 1) - 2)

def main():
	tc = int(input())
	for _ in range(tc):
		solve()
main()


n = int(input())
for _ in range(n):
	s = input()
	a = '0'
	b = '0'
	for g in range(len(s)):
		if g % 2 == 0:
			a += s[g]
		else:
			b += s[g]
	p = 1 + int(a)
	q = 1 + int(b)
	print(p * q - 2)


import sys
tc = int(sys.stdin.readline())
cache1 = {0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 7, 7: 8, 8: 9, 9: 10}
cache2 = {0: 9, 1: 8, 2: 7, 3: 6, 4: 5, 5: 4, 6: 3, 7: 2, 8: 1, 9: 0}
for _ in range(tc):
	arr = list(sys.stdin.readline().rstrip())
	size = len(arr)
	ans = 0
	for i in range(1 << size):
		temp = 1
		for j in range(size):
			if i & 1 << j != 0:
				if j > 1:
					if j + 2 < size and i & 1 << j + 2:
						now = int(arr[size - 1 - j]) - 1
						if now >= 0:
							temp *= cache2[now]
						else:
							temp *= cache1[now % 10]
					else:
						now = int(arr[size - 1 - j]) - 1
						if now >= 0:
							temp *= cache1[now]
						else:
							temp = 0
				else:
					temp = 0
			elif j + 2 < size and i & 1 << j + 2:
				now = int(arr[size - 1 - j])
				if now >= 0:
					temp *= cache2[now]
				else:
					temp = 0
			else:
				now = int(arr[size - 1 - j])
				temp *= cache1[now]
		ans += temp
	print(ans - 2)


import sys
strings = iter(sys.stdin.read().split())
ints = (int(x) for x in strings)
sys.setrecursionlimit(3000)

def f(a, carry=0):
	ans = 0
	if len(a) == 0:
		ans += carry == 0
	else:
		(*b, msd) = a
		if carry == 0:
			ans += (msd + 1) * f(b)
			if msd:
				ans += msd * f(b, carry=1)
		elif carry == 2:
			if 9 - msd:
				ans += (9 - msd) * f(b, carry=0)
			ans += (10 - msd) * f(b, carry=1)
		elif carry == 3:
			if 9 - msd:
				ans += (9 - msd) * f(b, carry=2)
			ans += (10 - msd) * f(b, carry=3)
		else:
			assert carry == 1
			ans += (msd + 1) * f(b, carry=2)
			if msd:
				ans += msd * f(b, carry=3)
	return ans

def main():
	ntc = next(ints)
	for tc in range(1, ntc + 1):
		a = tuple([int(c) for c in next(strings)][::-1])
		print(f(a) - 2)
	return
main()


def solve(x):
	(o, e) = ('', '')
	for i in range(len(x)):
		if i % 2 == 0:
			e += x[i]
		else:
			o += x[i]
	if o == '':
		o = 0
	if e == '':
		e = 0
	print((int(e) + 1) * (int(o) + 1) - 2)
for _ in range(int(input())):
	x = input()
	solve(x)


from collections import Counter, defaultdict
from sys import stdin, stdout
import io, os, sys
input = stdin.readline

def mapinput():
	return map(int, input().split())

def listinput():
	return list(map(int, input().split()))

def intinput():
	return int(stdin.readline())

def strinput():
	return input().strip()

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	ans = []
	for p in range(n + 1):
		if prime[p]:
			ans.append(p)
	return ans

def writ(ss):
	stdout.write(str(ss) + '\n')
for test in range(int(input())):

	def solve():
		n = strinput()
		return (int('0' + ''.join([n[i] for i in range(0, len(n), 2)])) + 1) * (int('0' + ''.join([n[i] for i in range(1, len(n), 2)])) + 1) - 2
	print(solve())


import sys
input = sys.stdin.readline

def solve():
	s = input().strip()
	n = len(s)
	dp1 = [0] * n
	dp2 = [0] * n
	if int(s) < 10:
		return int(s) - 1
	s = s[::-1]
	(d0, d1) = (int(s[0]), int(s[1]))
	(dp1[0], dp2[0]) = (d0 + 1, 9 - d0)
	(dp1[1], dp2[1]) = (d1 + 1, 9 - d1)
	for i in range(2, n):
		d = int(s[i])
		dp1[i] = (d + 1) * dp1[i - 2] + d * dp2[i - 2]
		dp2[i] = (9 - d) * dp1[i - 2] + (9 - d + 1) * dp2[i - 2]
	return dp1[-1] * dp1[-2] - 2
for _ in range(int(input())):
	print(solve())


from sys import stdin
input = stdin.readline
rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input().strip()
YN = lambda x: print('YES') if x else print('NO')
mod = 10 ** 9 + 7
for _ in range(rn()):
	n = rs()
	a = ''
	b = ''
	for i in range(len(n)):
		if i & 1:
			a += n[i]
		else:
			b += n[i]

	def f(s):
		if not s:
			return 1
		return int(s) + 1
	ans = f(a) * f(b)
	print(max(ans - 2, 0))


for _ in range(int(input())):
	n = int(input())
	s = str(n)
	e = ''
	o = ''
	for i in range(len(s)):
		if i % 2 == 0:
			e = e + s[i]
		else:
			o = o + s[i]
	if len(e) >= 1 and len(o) >= 1:
		q = int(e)
		t = int(o)
		print((q + 1) * (t + 1) - 2)
	else:
		q = int(e)
		print(q + 1 - 2)


import bisect
import heapq
import math
import sys
input = lambda : sys.stdin.readline().rstrip()
memo = [0] * 200
for i in range(110):
	for j in range(110):
		if i % 10 + j % 10 >= 10 or i // 10 + j // 10 >= 10:
			continue
		else:
			memo[i + j] += 1

def solve(n):
	if n == None:
		n = str(input())
	x = 0
	y = 0
	xnow = 1
	ynow = 1
	n = str(n)
	for i in range(len(n) - 1, -1, -1):
		if i % 2 == 0:
			x += int(n[i]) * xnow
			xnow *= 10
		else:
			y += int(n[i]) * ynow
			ynow *= 10
	return (x + 1) * (y + 1)
t = int(input())
for _ in range(t):
	print(solve(None) - 2)


t = int(input())
for i in range(t):
	s = input()
	n = len(s)
	s1 = ''
	s2 = ''
	for i in range(0, n, 2):
		s1 += s[i]
	for i in range(1, n, 2):
		s2 += s[i]
	k1 = int(s1)
	k2 = 0 if s2 == '' else int(s2)
	print((k1 + 1) * (k2 + 1) - 2)


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))

def calc(num):
	return max(0, 10 - abs(num - 9))
t = read_int()
for case_num in range(t):
	n = read_int()
	digits = [int(ch) for ch in str(n)][::-1]
	m = len(digits)
	ans = 0
	for state in range(1 << max(0, m - 2)):
		i = state << 2
		carry = [0] * m
		s = list(digits)
		for j in range(m):
			if i & 1 << j:
				carry[j] = 1
				s[j - 2] += 10
		choice = 1
		for j in range(m):
			num = s[j] - carry[j]
			choice *= calc(num)
			if choice == 0:
				break
		ans += choice
	print(ans - 2)


t = int(input())
for i in range(0, t):
	n = input()
	a = [None] * 1
	b = [None] * 1
	count = 0
	for j in n:
		if count == 0:
			a[0] = j
		elif count % 2 == 0:
			a.append(j)
		elif count == 1:
			b[0] = j
		else:
			b.append(j)
		count += 1
	if a[0] != None:
		a = int(''.join(a))
	else:
		a = 0
	if b[0] != None:
		b = int(''.join(b))
	else:
		b = 0
	total = (a + 1) * (b + 1) - 2
	print(total)


import sys
input = sys.stdin.readline

def quants(n, p):
	l = int(n[-1])
	if len(n) == 1:
		if p[0] == 1:
			return 0
		return l - p[1] + 1
	l = l - p[1]
	ans = 0
	if l + 1 > 0:
		ans += (l + 1) * quants(n[:-1], [0, p[0]])
	if 9 - l > 0:
		ans += (9 - l) * quants(n[:-1], [1, p[0]])
	return ans
for _ in range(int(input())):
	print(quants(input().strip(), [0, 0]) - 2)


for _ in range(int(input())):
	s = input()
	a = 0
	try:
		a = int(s[1::2])
	except:
		a = 0
	print((int(s[::2]) + 1) * (a + 1) - 2)


t = int(input())
while t:
	a = ''
	b = ''
	n = str(input())
	for i in range(1, len(n), 2):
		b += n[i]
	for i in range(0, len(n), 2):
		a += n[i]
	if a == '':
		a = 0
	if b == '':
		b = 0
	print((int(a) + 1) * (int(b) + 1) - 2)
	t -= 1


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
from bisect import bisect_left as lower_bound, bisect_right as upper_bound

def so():
	return int(input())

def st():
	return input()

def mj():
	return map(int, input().strip().split(' '))

def msj():
	return map(str, input().strip().split(' '))

def le():
	return list(map(int, input().split()))

def lebe():
	return list(map(int, input()))

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()

def joro(L):
	return ''.join(map(str, L))

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def npr(n, r):
	return factorial(n) // factorial(n - r) if n >= r else 0

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r)) if n >= r else 0

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def tir(a, b, c):
	if 0 == c:
		return 1
	if len(a) <= b:
		return 0
	if c != -1:
		return tir(a, 1 + b, c + a[b]) or tir(a, b + 1, c - a[b]) or tir(a, 1 + b, c)
	else:
		return tir(a, 1 + b, a[b]) or tir(a, b + 1, -a[b]) or tir(a, 1 + b, -1)

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = -1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, len(prime)):
		if prime[p]:
			li.append(p)
	return li

def primefactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n //= 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n //= i
	if n > 2:
		factors.append(n)
	return factors

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def tr(n):
	return n * (n + 1) // 2

def ti(x):
	import math
	if x >= 0:
		s = math.sqrt(x)
	if s * s == x:
		return 1
	return 0

def iu():
	import re
	import sys
	input = sys.stdin.readline
	import math as my
	s = st()
	m = len(s)
	x = 0
	y = 0
	for i in range(m):
		if i % 2 != 0:
			x = 10 * x + (ord(s[i]) - ord('0'))
		else:
			y = 10 * y + (ord(s[i]) - ord('0'))
	print((1 + x) * (1 + y) - 2)

def main():
	for i in range(so()):
		iu()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]
INF = 10 ** 10

def solve(S):
	D = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
	S = list(S)
	S.reverse()
	ans = 0
	for mask in range(2 ** (max(len(S), 2) - 2)):
		T = [int(c) for c in S]
		for i in range(len(S) - 2):
			if mask & 1 << i:
				T[i] += 10
				T[i + 2] -= 1
		n = 1
		for i in range(len(S)):
			if T[i] < 0:
				n = 0
			else:
				n *= D[T[i]]
		if mask == 0:
			n -= 2
		if n > 0:
			ans += n
	return ans
T0 = int(input())
for _ in range(T0):
	S = input()
	print(solve(S))


def main():
	s = input()
	n = len(s)
	ans = ''
	for i in range(0, n, 2):
		ans += s[i]
	n1 = int(ans)
	ans = ''
	for i in range(1, n, 2):
		ans += s[i]
	if ans == '':
		ans = '0'
	n2 = int(ans)
	ans = (n1 + 1) * (n2 + 1) - 2
	print(ans)
t = 1
t = int(input())
for ii in range(t):
	main()


from sys import *
input = stdin.readline
import random
from bisect import *
import math
from collections import *
import operator
from heapq import *
from itertools import *
inf = 10 ** 18
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = input()[:-1]
	a = ''
	b = ''
	for i in range(len(n)):
		if i % 2:
			a += n[i]
		else:
			b += n[i]
	if len(a):
		a = int(a) + 1
	else:
		a = 1
	if len(b):
		b = int(b) + 1
	else:
		b = 1
	print(a * b - 2)


t = int(input())
while t > 0:
	n = input()
	l1 = []
	l2 = []
	for i in range(len(n)):
		if i % 2 == 0:
			l1.append(n[i])
		else:
			l2.append(n[i])
	n1 = n2 = 0
	if len(l1) > 0:
		n1 = int(''.join(l1))
	if len(l2) > 0:
		n2 = int(''.join(l2))
	sol = (n1 + 1) * (n2 + 1) - 2
	print(sol)
	t -= 1


T = int(input())
for _ in range(T):
	n = input()
	even = 0
	odd = 0
	for i in range(len(n)):
		if i % 2 == 0:
			even = even * 10 + int(n[i])
		else:
			odd = odd * 10 + int(n[i])
	print((even + 1) * (odd + 1) - 2)


def conv(x):
	if x == '':
		return 1
	return int(x) + 1

def main():
	n = input()
	l = len(n)
	(a, b) = ('', '')
	for i in range(0, len(n), 2):
		a += n[i]
	for i in range(1, len(n), 2):
		b += n[i]
	print(conv(a) * conv(b) - 2)
t = int(input())
for i in range(t):
	main()


import array
import bisect
import heapq
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def ints_get():
	return map(int, input().strip().split())

def list_get():
	return list(map(int, sys.stdin.readline().strip().split()))

def chars_get():
	return list(map(str, sys.stdin.readline().strip().split()))

def output(to_be_printed, end='\n'):
	sys.stdout.write(str(to_be_printed) + end)

def main():
	t = int(input())
	for _ in range(t):
		n = [int(x) for x in input()]
		a = []
		b = []
		n.reverse()
		for i in range(len(n)):
			if i % 2 == 0:
				a.append(n[i])
			else:
				b.append(n[i])
		s1 = 0
		s2 = 0
		for i in range(len(a)):
			s1 += a[i] * 10 ** i
		for i in range(len(b)):
			s2 += b[i] * 10 ** i
		output((s1 + 1) * (s2 + 1) - 2)
	return
main()


import sys
import os
cin = [lambda : input(), lambda : int(input()), lambda : input().split(), lambda : [int(a) for a in input().split()]]

def solve():
	n = cin[0]()
	l = len(n)
	if l == 1:
		print(int(n) - 1)
		return
	o = e = ''
	for i in range(l):
		if i % 2 == 0:
			e += n[i]
		else:
			o += n[i]
	if o != '' and e != '':
		a = int(o)
		b = int(e)
		print((a + 1) * (b + 1) - 2)
	elif o == '':
		print(max(0, int(e) - 1))
	else:
		print(max(0, int(o) - 1))

def main():
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = cin[1]()
	while t:
		t -= 1
		solve()
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = input()[:-1][::-1]
	L = len(n)
	dp = [[[0] * 2 for _ in range(2)] for _ in range(L + 1)]
	dp[0][0][0] = 1
	for i in range(L):
		a = int(n[i]) + 1
		b = 9 - int(n[i])
		dp[i + 1][0][0] += a * dp[i][0][0]
		dp[i + 1][0][1] += b * dp[i][0][0]
		dp[i + 1][1][0] += a * dp[i][0][1]
		dp[i + 1][1][1] += b * dp[i][0][1]
		a = int(n[i])
		b = 10 - int(n[i])
		dp[i + 1][0][0] += a * dp[i][1][0]
		dp[i + 1][0][1] += b * dp[i][1][0]
		dp[i + 1][1][0] += a * dp[i][1][1]
		dp[i + 1][1][1] += b * dp[i][1][1]
	print(dp[L][0][0] - 2)


t = int(input())
for i in range(t):
	n = input()
	if len(n) == 1:
		print(int(n) - 1)
	else:
		ns = [char for char in n]
		se = ''
		so = ''
		for i in range(len(ns)):
			if i % 2 == 0:
				se += ns[i]
			else:
				so += ns[i]
		se = int(se) + 1
		so = int(so) + 1
		print(se * so - 2)


def main(n):
	vals = [0, 0]
	idx = 0
	l = 0
	while n:
		d = n % 10
		vals[idx] += d * pow(10, l)
		n //= 10
		idx ^= 1
		if idx == 0:
			l += 1
	if vals[0] == 0 or vals[1] == 0:
		return max(vals) - 1
	else:
		return (vals[0] + 1) * (vals[1] + 1) - 2
t = int(input())
ans = []
for i in range(t):
	ans.append(main(int(input())))
for e in ans:
	print(e)


import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import *
from collections import defaultdict, deque, Counter
import math, string
from heapq import *
from operator import add
from itertools import accumulate
BUFSIZE = 8192
sys.setrecursionlimit(10 ** 5)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
inf = float('inf')
en = lambda x: list(enumerate(x))
ceil_ = lambda a, b: (a + b - 1) // b
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())

def solve():
	n = '00' + input()
	a = n[::2]
	b = n[1::2]
	a = int(a) + 1
	b = int(b) + 1
	print(a * b - 2)
for _ in ' ' * ii():
	solve()


t = int(input())
for i in range(t):
	n = input()
	(a, b) = ('', '')
	for i in range(0, len(n), 2):
		a += n[i]
	for i in range(1, len(n), 2):
		b += n[i]
	if a:
		a = int(a)
	if b:
		b = int(b)
	if not b:
		b = 0
	if not a:
		a = 0
	print((a + 1) * (b + 1) - 2)


for _ in range(int(input())):
	n = input()
	if len(n) == 1:
		print(int(n) - 1)
	else:
		n1 = ''
		n2 = ''
		for i in range(len(n)):
			if i % 2 == 0:
				n1 += n[i]
			else:
				n2 += n[i]
		ans = (int(n1) + 1) * (int(n2) + 1) - 2
		print(ans)


digit_map = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

def count(n, crr_neg, crr_pos):
	n_ = [int(x) for x in list(str(n))]
	assert len(crr_neg) == len(n_)
	assert len(crr_pos) == len(n_)
	v = 1
	for (idx, (d, c_neg, c_pos)) in enumerate(zip(n_, crr_neg, crr_pos)):
		d += c_neg + 10 * c_pos
		if d < 0 or d >= 19:
			return 0
		v *= digit_map[d]
	return v

def generate_carry_patterns(n):
	if n > 2:
		for i in range(2 ** (n - 2)):
			crr_neg = [int(x) * -1 for x in bin(i)[2:]] + [0, 0]
			while len(crr_neg) < n:
				crr_neg = [0] + crr_neg
			crr_pos = [0] * len(crr_neg)
			for j in range(n - 3, -1, -1):
				if crr_neg[j] == -1:
					crr_pos[j + 2] += 1
			yield (crr_neg, crr_pos)
	else:
		yield ([0] * n, [0] * n)

def count_all(N):
	num_digits = len(str(N))
	tot = 0
	for (crr_neg, crr_pos) in generate_carry_patterns(num_digits):
		s = count(N, crr_neg, crr_pos)
		tot += s
	return tot - 2
T = int(input())
while T > 0:
	T -= 1
	n = int(input())
	cnt = count_all(n)
	print(cnt)


def solve():
	s = '0' + input()
	(a, b) = (int(s[0::2]) + 1, int(s[1::2]) + 1)
	print(a * b - 2)

def main():
	tc = int(input())
	for _ in range(tc):
		solve()
main()


for i in range(int(input())):
	st = input()
	a = ''
	b = ''
	for k in range(0, len(st)):
		if k % 2 == 0:
			a += st[k]
		else:
			b += st[k]
	if a == '':
		a = 0
	if b == '':
		b = 0
	n = (int(a) + 1) * (int(b) + 1) - 2
	print(n)


for _ in range(int(input())):
	num = str(input())
	(e, n_e) = ('', '')
	for ind in range(len(num)):
		if ind % 2 == 0:
			e += num[ind]
		else:
			n_e += num[ind]
	if n_e == '':
		ans = int(e) - 1
	else:
		ans = (int(e) + 1) * (int(n_e) + 1) - 2
	print(ans)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		n = input()[:-1]
		odd = 0
		even = 0
		for (i, x) in enumerate(n):
			if i % 2:
				even += int(x)
				even *= 10
			else:
				odd += int(x)
				odd *= 10
		print((even // 10 + 1) * (odd // 10 + 1) - 2)
main()


T = int(input())
for t in range(T):
	n = input()
	a = ''
	b = ''
	for (i, c) in enumerate(n[::-1]):
		if i % 2 == 0:
			a = c + a
		else:
			b = c + b
	a = int(a)
	if b:
		b = int(b)
	else:
		b = 0
	res = (a + 1) * (b + 1) - 2
	print(res)


from collections import deque
import heapq
from math import sqrt
import operator
from operator import itemgetter
import sys
import copy
inf_var = 0
if inf_var == 1:
	inf = open('input.txt', 'r')
else:
	inf = sys.stdin
input = inf.readline

def read_one_int():
	return int(input().rstrip('\n'))

def read_one_float():
	return float(input().rstrip('\n'))

def read_list_of_ints():
	res = [int(val) for val in input().rstrip('\n').split(' ')]
	return res

def read_str():
	return input().rstrip()

def main():
	tests = read_one_int()
	for _ in range(tests):
		cur_str = read_str()
		first_num = ''
		second_num = ''
		for (i, ch) in enumerate(cur_str):
			if not i % 2:
				first_num += ch
			else:
				second_num += ch
		if not second_num:
			res = int(first_num) - 1
			print(res)
			continue
		first_num = int(first_num)
		second_num = int(second_num)
		res = (first_num + 1) * (second_num + 1) - 2
		print(res)
main()


t = int(input())
for _ in range(t):
	n = str(input())
	(a, b) = ('', '')
	n = n[::-1]
	odd = False
	for c in n:
		if odd:
			b += c
		else:
			a += c
		odd = not odd
	a = int('0' + a[::-1])
	b = int('0' + b[::-1])
	print((a + 1) * (b + 1) - 2)


for _ in range(int(input())):
	n = int(input())
	c1 = 1
	c2 = 1
	i = 0
	a = 0
	b = 0
	while n:
		r = int(n % 10)
		if int(i % 2) == 0:
			a = r * c1 + a
			c1 *= 10
		else:
			b = r * c2 + b
			c2 *= 10
		n = int(n / 10)
		i += 1
	print((a + 1) * (b + 1) - 2)


for _ in range(int(input())):
	n = input()
	a = ''
	b = ''
	for i in range(len(n)):
		if i % 2 == 0:
			a += n[i]
		else:
			b += n[i]
	if len(a) > 0 and len(b) > 0:
		print((int(a) + 1) * (int(b) + 1) - 2)
	elif len(a) > 0:
		print(int(a) - 1)
	else:
		print(int(b) - 1)


t = int(input())
for i in range(t):
	n = int(input())
	arr = str(n)
	ans = ''
	ans1 = ''
	for i in range(len(arr)):
		if i % 2 == 0:
			ans += arr[i]
		else:
			ans1 += arr[i]
	if len(arr) == 1:
		print(int(ans) - 1)
	else:
		a = (int(ans) + 1) * (int(ans1) + 1)
		print(a - 2)


def rec(pos, c, count_before, a_before, b_before):
	global count
	if pos < -l:
		if a_before != 0 and b_before != 0:
			count += count_before
		return
	c1 = c.copy()
	c2 = c.copy()
	c2[pos - 2] += 1
	count1 = 0
	count2 = 0
	count0 = 0
	for a in range(10):
		a_now = a_before * 10 + a
		b = (d[pos] - a - c[pos]) % 10
		b_now = b_before * 10 + b
		if a + b + c[pos] == d[pos]:
			if a_now != 0 and b_now != 0:
				count1 += 1
			else:
				rec(pos - 1, c1, count_before, a_now, b_now)
		elif a + b + c[pos] == d[pos] + 10:
			if -(pos - 2) <= l:
				if a_now != 0 and b_now != 0:
					count2 += 1
				else:
					rec(pos - 1, c2, count_before, a_now, b_now)
	if count1 > 0:
		rec(pos - 1, c1, count_before * count1, 1, 1)
	if count2 > 0:
		rec(pos - 1, c2, count_before * count2, 1, 1)
	return
T = int(input())
for testcase in range(1, T + 1):
	count = 0
	n = int(input())
	d = [int(x) for x in str(n)]
	c = [0 for x in range(len(d) + 3)]
	l = len(d)
	rec(-1, c, 1, 0, 0)
	print(count)


for a in [*open(0)][1:]:
	print((1 + int(a[::2])) * (1 + int('0' + a[1::2])) - 2)


import sys
from collections import defaultdict, deque
from bisect import bisect_left
import math
input = sys.stdin.readline

def inp():
	l = list(map(int, input().split()))
	return l
for _ in range(int(input())):
	n = input()
	s1 = '0'
	s2 = '0'
	for i in range(len(n)):
		if i % 2 == 0:
			s1 += n[i]
		else:
			s2 += n[i]
	s1 = int(s1)
	s2 = int(s2)
	print((s1 + 1) * (s2 + 1) - 2)


import sys
from functools import lru_cache
input = lambda : sys.stdin.readline().strip()

class Solution:

	def __init__(self, s):
		self.s = s
		self.n = len(s)

	def solve(self):

		@lru_cache(None)
		def dp(idx, carry, carry1):
			if idx >= len(s):
				if carry or carry1:
					return 0
				return 1
			ans = 0
			for d1 in range(10):
				for d2 in range(10):
					su = carry + d1 + d2
					if su % 10 != int(s[idx]):
						continue
					ans += dp(idx + 1, carry1, su // 10)
			return ans
		return dp(0, 0, 0)
t = int(input())
while t:
	t -= 1
	s = input()
	s = s[::-1]
	ans = Solution(s).solve()
	print(ans - 2)


def f(p, n, carries, acc):
	if p == -1:
		return acc
	ret = 0
	for carry in range(2):
		if p < 2 and carry == 1:
			continue
		target = n[p] - carry + carries[p + 2] * 10
		if target < 0:
			continue
		if target >= 10:
			curr = 19 - target
		else:
			curr = target + 1
		if curr > 0:
			carries[p] = carry
			ret += f(p - 1, n, carries, acc * curr)
	return ret
T = int(input())
for _ in range(T):
	n = tuple(map(int, reversed(input())))
	carries = [0] * 12
	answer = f(len(n) - 1, n, carries, 1) - 2
	print(answer)


test = int(input())
for i in range(test):
	t = input()
	odd = ''
	even = ''
	for i in range(len(t)):
		if i % 2 == 0:
			odd += t[i]
		else:
			even += t[i]
	odd = int(odd) + 1
	if even:
		even = int(even) + 1
	else:
		even = 1
	print(odd * even - 2)


import math
import heapq
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	n = I()
	s = str(n)
	(s1, s2) = ('0', '0')
	for i in range(len(s)):
		if i % 2 == 0:
			s1 += s[i]
		else:
			s2 += s[i]
	print((int(s1) + 1) * (int(s2) + 1) - 2)


def naiveSolve():
	return

def solve():
	return

def main():
	t = int(input())
	allans = []
	for _ in range(t):
		n = int(input())
		even = 0
		odd = 0
		m = 1
		isEven = True
		while n:
			if isEven:
				even += n % 10 * m
			else:
				odd += n % 10 * m
				m *= 10
			n //= 10
			isEven = not isEven
		allans.append((even + 1) * (odd + 1) - 2)
	multiLineArrayPrint(allans)
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(x):
	print('{}'.format(x))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ans):
	print('! {}'.format(ans))
	sys.stdout.flush()
inf = float('inf')
from math import gcd, floor, ceil
for _abc in range(1):
	main()


t = int(input())
for i in range(t):
	s = input()
	s1 = 0
	s2 = 0
	for j in range(len(s)):
		if j % 2 == 0:
			s1 = s1 * 10 + int(s[j])
		else:
			s2 = s2 * 10 + int(s[j])
	print((s1 + 1) * (s2 + 1) - 2)


import sys
INF = float('inf')
MOD = 10 ** 9 + 7
MOD2 = 998244353
from collections import defaultdict

def solve():

	def II():
		return int(sys.stdin.readline())

	def LI():
		return list(map(int, sys.stdin.readline().split()))

	def LC():
		return list(input())

	def IC():
		return [int(c) for c in input()]

	def MI():
		return map(int, sys.stdin.readline().split())
	T = II()
	for _ in range(T):
		N = IC()
		Odd = []
		Even = []
		for (i, n) in enumerate(N):
			if i % 2 == 0:
				Even.append(n)
			else:
				Odd.append(n)
		Even.reverse()
		Odd.reverse()
		O = 0
		E = 0
		for (i, n) in enumerate(Odd):
			O += 10 ** i * n
		for (i, n) in enumerate(Even):
			E += 10 ** i * n
		print((O + 1) * (E + 1) - 2)
	return
solve()


import sys
import os
from math import *
LOCAL = not __debug__

def conv(x):
	try:
		return int(x) + 1
	except:
		return 1

def main():
	n = input()
	l = len(n)
	(a, b) = ('', '')
	for i in range(0, len(n), 2):
		a += n[i]
	for i in range(1, len(n), 2):
		b += n[i]
	ans = conv(a) * conv(b) - 2
	print(ans)
if LOCAL:
	sys.stdin = open('hack.txt', 'r')
	sys.stdout = open('hack.out', 'w')
t = int(input())
for i in range(t):
	main()