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 final class Main {
  
      static PrintWriter out = new PrintWriter(System.out);
      static FastReader in = new FastReader();
      static Pair[] moves = new Pair[]{new Pair(-1, 0), new Pair(1, 0), new Pair(0, -1), new Pair(0, 1)};
      static int mod = (int) (1e9 + 7);
  
      public static void main(String[] args) {
          int tt = i();
          while (tt-- > 0) {
              solve();
          }
          out.flush();
      }
  
      // 12345
  
      // 1
      // 0 2 13 4 5
  
      private static int cal(int x) {
          if (x >= 0 && x <= 9) {
              return x + 1;
          } else if (x >= 10 && x <= 18) {
              return 19 - x;
          } else {
              return 0;
          }
      }
  
      private static void solve() {
          String s = s();
          int n = s.length();
          if (n == 1) {
              out.println(cal(Integer.parseInt(s)) - 2);
              return;
          }
          int[][] dp = new int[n][20];
          for (int i = n - 1; i >= 0; i --) {
              int cur = s.charAt(i) - '0';
              if (i + 2 < n) {
                  for (int j = 0; j < 10; j++) {
                      dp[i][cur] += dp[i + 2][j] * cal(cur);
                      dp[i][cur + 10] += dp[i + 2][j] * cal(cur + 10);
                  }
                  for (int j = 10; j < 20; j++) {
                      dp[i][cur] += dp[i + 2][j] * cal(cur - 1);
                      dp[i][cur + 10] += dp[i + 2][j] * cal(cur + 9);
                  }
              } else {
                  dp[i][cur] += cal(cur);
                  dp[i][cur + 10] = cal(cur + 10);
              }
          }
          int ans = 0;
          for (int i = 0; i < 10; i++) {
              ans += dp[0][i];
          }
          int ans2 = 0;
          for (int i = 0; i < 10; i++) {
              ans2 += dp[1][i];
          }
          out.println(ans * ans2 - 2);
      }
  
      static int[] pre(int[] a) {
          int[] pre = new int[a.length];
          pre[0] = a[0];
          for (int i = 1; i < a.length; i++) {
              pre[i] = pre[i - 1] + a[i];
          }
          return pre;
      }
  
      static int[] preRev(int[] a) {
          int[] pre = new int[a.length];
          pre[a.length - 1] = a[a.length - 1];
          for (int i = a.length - 2; i >= 0; i--) {
              pre[i] = pre[i + 1] + a[i];
          }
          return pre;
      }
  
      static void print(char A[]) {
          for (char c : A) {
              out.print(c);
          }
          out.println();
      }
  
      static void print(boolean A[]) {
          for (boolean c : A) {
              out.print(c + " ");
          }
          out.println();
      }
  
      static void print(int A[]) {
          for (int c : A) {
              out.print(c + " ");
          }
          out.println();
      }
  
      static void print(long A[]) {
          for (long i : A) {
              out.print(i + " ");
          }
          out.println();
      }
  
      static void print(List<Integer> A) {
          for (int a : A) {
              out.print(a + " ");
          }
      }
  
      static int i() {
          return in.nextInt();
      }
  
      static long l() {
          return in.nextLong();
      }
  
      static String s() {
          return in.nextLine();
      }
  
      static int[][] inputWithIdx(int N) {
          int A[][] = new int[N][2];
          for (int i = 0; i < N; i++) {
              A[i] = new int[]{i, in.nextInt()};
          }
          return A;
      }
  
      static int[] input(int N) {
          int A[] = new int[N];
          for (int i = 0; i < N; i++) {
              A[i] = in.nextInt();
          }
          return A;
      }
  
      static long[] inputLong(int N) {
          long A[] = new long[N];
          for (int i = 0; i < A.length; i++) {
              A[i] = in.nextLong();
          }
          return A;
      }
  
      static int GCD(int a, int b) {
          if (b == 0) {
              return a;
          } else {
              return GCD(b, a % b);
          }
      }
  
      static long GCD(long a, long b) {
          if (b == 0) {
              return a;
          } else {
              return GCD(b, a % b);
          }
      }
  
      static long LCM(int a, int b) {
          return (long) a / GCD(a, b) * b;
      }
  
      static long LCM(long a, long b) {
          return a / GCD(a, b) * b;
      }
  
      static void shuffleAndSort(int[] arr) {
          for (int i = 0; i < arr.length; i++) {
              int rand = (int) (Math.random() * arr.length);
              int temp = arr[rand];
              arr[rand] = arr[i];
              arr[i] = temp;
          }
          Arrays.sort(arr);
      }
  
      static void shuffleAndSort(int[][] arr, Comparator<? super int[]> comparator) {
          for (int i = 0; i < arr.length; i++) {
              int rand = (int) (Math.random() * arr.length);
              int[] temp = arr[rand];
              arr[rand] = arr[i];
              arr[i] = temp;
          }
          Arrays.sort(arr, comparator);
      }
  
      static void shuffleAndSort(long[] arr) {
          for (int i = 0; i < arr.length; i++) {
              int rand = (int) (Math.random() * arr.length);
              long temp = arr[rand];
              arr[rand] = arr[i];
              arr[i] = temp;
          }
          Arrays.sort(arr);
      }
  
      static boolean isPerfectSquare(double number) {
          double sqrt = Math.sqrt(number);
          return ((sqrt - Math.floor(sqrt)) == 0);
      }
  
      static void swap(int A[], int a, int b) {
          int t = A[a];
          A[a] = A[b];
          A[b] = t;
      }
  
      static long pow(long a, long b, int mod) {
          long pow = 1;
          long x = a;
          while (b != 0) {
              if ((b & 1) != 0) {
                  pow = (pow * x) % mod;
              }
              x = (x * x) % mod;
              b /= 2;
          }
          return pow;
      }
  
      static long pow(long a, long b) {
          long pow = 1;
          long x = a;
          while (b != 0) {
              if ((b & 1) != 0) {
                  pow *= x;
              }
              x = x * x;
              b /= 2;
          }
          return pow;
      }
  
      static long modInverse(long x, int mod) {
          return pow(x, mod - 2, mod);
      }
  
      static boolean isPrime(long N) {
          if (N <= 1) {
              return false;
          }
          if (N <= 3) {
              return true;
          }
          if (N % 2 == 0 || N % 3 == 0) {
              return false;
          }
          for (int i = 5; i * i <= N; i = i + 6) {
              if (N % i == 0 || N % (i + 2) == 0) {
                  return false;
              }
          }
          return true;
      }
  
      public static String reverse(String str) {
          if (str == null) {
              return null;
          }
          return new StringBuilder(str).reverse().toString();
      }
  
      public static String repeat(char ch, int repeat) {
          if (repeat <= 0) {
              return "";
          }
          final char[] buf = new char[repeat];
          for (int i = repeat - 1; i >= 0; i--) {
              buf[i] = ch;
          }
          return new String(buf);
      }
  
      public static int[] manacher(String s) {
          char[] chars = s.toCharArray();
          int n = s.length();
          int[] d1 = new int[n];
          for (int i = 0, l = 0, r = -1; i < n; i++) {
              int k = (i > r) ? 1 : Math.min(d1[l + r - i], r - i + 1);
              while (0 <= i - k && i + k < n && chars[i - k] == chars[i + k]) {
                  k++;
              }
              d1[i] = k--;
              if (i + k > r) {
                  l = i - k;
                  r = i + k;
              }
          }
          return d1;
      }
  }
  
  class Pair {
  
      int i, j;
  
      Pair(int i, int j) {
          this.i = i;
          this.j = j;
      }
  }
  
  class FastReader {
  
      BufferedReader br;
      StringTokenizer st;
  
      public FastReader() {
          br = new BufferedReader(new InputStreamReader(System.in));
      }
  
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
  
      int nextInt() {
          return Integer.parseInt(next());
      }
  
      long nextLong() {
          return Long.parseLong(next());
      }
  
      double nextDouble() {
          return Double.parseDouble(next());
      }
  
      String nextLine() {
          String str = "";
          try {
              str = br.readLine();
          } catch (IOException e) {
              e.printStackTrace();
          }
          return str;
      }
  }