description: Alice has just learned addition. However, she hasn't learned the concept of "carrying" fully — instead of carrying to the next column, she carries to the column two columns to the left.
  
  For example, the regular way to evaluate the sum 2039 + 2976 would be as shown: 
  
  <image>
  
  However, Alice evaluates it as shown: 
  
  <image>
  
  In particular, this is what she does: 
  
    * add 9 and 6 to make 15, and carry the 1 to the column two columns to the left, i. e. to the column "0 9"; 
    * add 3 and 7 to make 10 and carry the 1 to the column two columns to the left, i. e. to the column "2 2"; 
    * add 1, 0, and 9 to make 10 and carry the 1 to the column two columns to the left, i. e. to the column above the plus sign; 
    * add 1, 2 and 2 to make 5; 
    * add 1 to make 1. 
  
  Thus, she ends up with the incorrect result of 15005.
  
  Alice comes up to Bob and says that she has added two numbers to get a result of n. However, Bob knows that Alice adds in her own way. Help Bob find the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n. Note that pairs (a, b) and (b, a) are considered different if a ≠ b.
  
  Input
  
  The input consists of multiple test cases. The first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases. The description of the test cases follows.
  
  The only line of each test case contains an integer n (2 ≤ n ≤ 10^9) — the number Alice shows Bob.
  
  Output
  
  For each test case, output one integer — the number of ordered pairs of positive integers such that when Alice adds them, she will get a result of n. 
  
  Example
  
  Input
  
  
  5
  100
  12
  8
  2021
  10000
  
  
  Output
  
  
  9
  4
  7
  44
  99
  
  Note
  
  In the first test case, when Alice evaluates any of the sums 1 + 9, 2 + 8, 3 + 7, 4 + 6, 5 + 5, 6 + 4, 7 + 3, 8 + 2, or 9 + 1, she will get a result of 100. The picture below shows how Alice evaluates 6 + 4: 
  
  <image>
solution: import java.io.*;
  import java.util.*;
  
  public class C {
  	static char[] a;
  	static long[][] memo;
  
  	static long dp(int idx, int msk) {
  		if (idx == a.length) {
  			boolean f = ((msk >> idx) & 1) == 0 && ((msk >> (idx + 1)) & 1) == 0;
  //			if (f)
  //				System.out.println(msk);
  			return f ? 1 : 0;
  		}
  		if (memo[idx][msk] != -1)
  			return memo[idx][msk];
  		int x = a[idx] - '0';
  		long ans = 0;
  		for (int i = 0; i <= 9; i++) {
  			int temp = x - i - ((msk >> idx) & 1);
  //			System.out.println(temp);
  			if (temp >= 0)
  				ans += dp(idx + 1, msk);
  
  			temp = x - i - ((msk >> idx) & 1) + 10;
  			if (temp >= 0 && temp < 10)
  				ans += dp(idx + 1, msk | (1 << (idx + 2)));
  
  		}
  		return memo[idx][msk] = ans;
  	}
  
  //	static int dp2(int idx, int msk) {
  //		
  //	}
  
  	public static void main(String[] args) throws IOException {
  		Scanner sc = new Scanner(System.in);
  		PrintWriter pw = new PrintWriter(System.out);
  
  		int t = sc.nextInt();
  		while (t-- > 0) {
  			int n = sc.nextInt();
  			char[] b = ("" + n).toCharArray();
  			a = new char[b.length];
  			for (int i = 0; i < b.length; i++) {
  				a[i] = b[b.length - 1 - i];
  			}
  			memo = new long[15][5000];
  			for (int i = 0; i < memo.length; i++) {
  				Arrays.fill(memo[i], -1);
  			}
  			pw.println(dp(0, 0) - 2);
  		}
  
  		pw.flush();
  	}
  
  	static class UnionFind {
  		int[] p, rank, setSize;
  		int numSets;
  
  		public UnionFind(int N) {
  			p = new int[numSets = N];
  			rank = new int[N];
  			setSize = new int[N];
  			for (int i = 0; i < N; i++) {
  				p[i] = i;
  				setSize[i] = 1;
  			}
  		}
  
  		public int findSet(int i) {
  			return p[i] == i ? i : (p[i] = findSet(p[i]));
  		}
  
  		public boolean isSameSet(int i, int j) {
  			return findSet(i) == findSet(j);
  		}
  
  		public void unionSet(int i, int j) {
  			if (isSameSet(i, j))
  				return;
  			numSets--;
  			int x = findSet(i), y = findSet(j);
  			if (rank[x] > rank[y]) {
  				p[y] = x;
  				setSize[x] += setSize[y];
  			} else {
  				p[x] = y;
  				setSize[y] += setSize[x];
  				if (rank[x] == rank[y])
  					rank[y]++;
  			}
  		}
  
  		public int numDisjointSets() {
  			return numSets;
  		}
  
  		public int sizeOfSet(int i) {
  			return setSize[findSet(i)];
  		}
  	}
  
  	static int mod = (int) (1e9 + 9);
  	static int base = 31;
  	static int[] pows;
  
  	static void makePows() {
  		pows = new int[500001];
  		pows[0] = 1;
  		for (int i = 1; i < pows.length; i++) {
  			pows[i] = (int) ((pows[i - 1] * 1l * base) % mod);
  		}
  	}
  
  	static class SegmentTree { // 1-based DS, OOP
  
  		int N; // the number of elements in the array as a power of 2 (i.e. after padding)
  		int[] array, sTree;
  
  		SegmentTree(int[] in) {
  			array = in;
  			N = in.length - 1;
  			sTree = new int[N << 1]; // no. of nodes = 2*N - 1, we add one to cross out index zero
  		}
  
  		void update_point(int index, int val) // O(log n)
  		{
  			index += N - 1;
  			sTree[index] = val;
  			while (index > 1) {
  				index >>= 1;
  				sTree[index] = (sTree[index << 1] + sTree[index << 1 | 1]) % mod;
  			}
  		}
  
  		int query(int i, int j) {
  			return query(1, 1, N, i, j);
  		}
  
  		int query(int node, int b, int e, int i, int j) // O(log n)
  		{
  			if (i > e || j < b)
  				return 0;
  			if (b >= i && e <= j)
  				return sTree[node];
  			int mid = b + e >> 1;
  			int q1 = query(node << 1, b, mid, i, j);
  			int q2 = query(node << 1 | 1, mid + 1, e, i, j);
  			return (q1 + q2) % mod;
  
  		}
  
  	}
  
  	static class Scanner {
  		StringTokenizer st;
  		BufferedReader br;
  
  		public Scanner(InputStream s) {
  			br = new BufferedReader(new InputStreamReader(s));
  		}
  
  		public String next() throws IOException {
  			while (st == null || !st.hasMoreTokens())
  				st = new StringTokenizer(br.readLine());
  			return st.nextToken();
  		}
  
  		public int nextInt() throws IOException {
  			return Integer.parseInt(next());
  		}
  
  		public long nextLong() throws IOException {
  			return Long.parseLong(next());
  		}
  
  		public String nextLine() throws IOException {
  			return br.readLine();
  		}
  
  		public double nextDouble() throws IOException {
  			String x = next();
  			StringBuilder sb = new StringBuilder("0");
  			double res = 0, f = 1;
  			boolean dec = false, neg = false;
  			int start = 0;
  			if (x.charAt(0) == '-') {
  				neg = true;
  				start++;
  			}
  			for (int i = start; i < x.length(); i++)
  				if (x.charAt(i) == '.') {
  					res = Long.parseLong(sb.toString());
  					sb = new StringBuilder("0");
  					dec = true;
  				} else {
  					sb.append(x.charAt(i));
  					if (dec)
  						f *= 10;
  				}
  			res += Long.parseLong(sb.toString()) / f;
  			return res * (neg ? -1 : 1);
  		}
  
  		public boolean ready() throws IOException {
  			return br.ready();
  		}
  
  	}
  
  }
  