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.math.BigInteger;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.StringTokenizer;
  
  public class Solution {
  
  
      private static class Config {
          private static final boolean useInputFile = false;
          private static final boolean useOutputFile = false;
          private static final String inputFile = "";
          private static final String outputFile = "";
      }
  
      public static void main(String[] args) throws Exception {
          run();
      }
  
      public static void run() throws Exception {
          FastScanner sc = new FastScanner();
          int t = 1;
          t = sc.nextInt();
          BufferedWriter writer = getWriter();
          for (int i = 0; i < t; i++)
              solve(sc, writer);
          writer.flush();
      }
  
      private static void generateCarriesUtil(int value, int index, int[] carry, List<Integer[]> result) {
          carry[index] = value;
          if (index >= carry.length - 1) {
              Integer[] f = new Integer[carry.length];
              for (int i = 0; i < carry.length; i++) {
                  f[i] = carry[i];
              }
              result.add(f);
              return;
          }
          generateCarriesUtil(0, index + 1, carry, result);
          generateCarriesUtil(1, index + 1, carry, result);
      }
  
      private static List<Integer[]> generateCarries(int n) {
          List<Integer[]> result = new ArrayList<>();
          int[] carry = new int[n];
          generateCarriesUtil(0, 0, carry, result);
          generateCarriesUtil(1, 0, carry, result);
          return result;
      }
  
      private static int calculateWays(Integer[] carry, String n) {
          int ans = 1;
          for (int i = carry.length - 1; i >= 0; i--) {
              int carryForward = 0;
              if (i >= 2) carryForward = carry[i - 2];
              if (i >= carry.length - 2 && carry[i] > 0) return 0;
              int num = n.charAt(i) - '0';
              num -= carry[i];
              int k = 0;
              if (carryForward == 0) {
                  for (int j = 0; j <= 9; j++)
                      if (j <= num)
                          k++;
              } else {
                  for (int j = 0; j <= 9; j++)
                      if (num + 10 - j < 10)
                          k++;
              }
              ans *= k;
          }
          return ans;
      }
  
      private static void solve(FastScanner sc, BufferedWriter writer) throws Exception {
          int n = sc.nextInt();
          String nStr = String.valueOf(n);
          List<Integer[]> carries = generateCarries(nStr.length());
          int ans = 0;
          for (Integer[] carry : carries) {
              ans += calculateWays(carry, nStr);
          }
          ans -= 2;
          writer.write(ans + "\n");
      }
  
      private static class Pair<A, B> {
          A first;
          B second;
  
          public Pair(A first, B second) {
              this.first = first;
              this.second = second;
          }
  
          public Pair() {
          }
      }
  
      private static class CustomBigInteger {
          private final BigInteger value;
  
          public CustomBigInteger(int value) {
              this.value = new BigInteger(String.valueOf(value));
          }
  
  
          public CustomBigInteger(String value) {
              this.value = new BigInteger(value);
          }
  
          public CustomBigInteger(long value) {
              this.value = new BigInteger(String.valueOf(value));
          }
  
          public CustomBigInteger(CustomBigInteger value) {
              this.value = new BigInteger(value.toString());
          }
  
          public CustomBigInteger(BigInteger value) {
              this.value = new BigInteger(value.toString());
          }
  
          @Override
          public String toString() {
              return this.value.toString();
          }
  
          public int toInt() {
              return Integer.parseInt(this.toString());
          }
  
          public boolean lessThan(CustomBigInteger value) {
              return this.value.compareTo(value.value) < 0;
          }
  
          public boolean equal(CustomBigInteger value) {
              return this.value.compareTo(value.value) == 0;
          }
  
          public boolean greaterThan(CustomBigInteger value) {
              return this.value.compareTo(value.value) > 0;
          }
  
          public boolean greaterThanOrEqual(CustomBigInteger value) {
              return this.greaterThan(value) || this.equal(value);
          }
  
          public boolean lessThanOrEqual(CustomBigInteger value) {
              return this.lessThan(value) || this.equal(value);
          }
  
          public static CustomBigInteger max(CustomBigInteger a, CustomBigInteger b) {
              if (a.greaterThan(b))
                  return a;
              return b;
          }
  
          public static CustomBigInteger min(CustomBigInteger a, CustomBigInteger b) {
              if (a.lessThan(b))
                  return a;
              return b;
          }
  
          public CustomBigInteger add(String value) {
              return new CustomBigInteger(
                      this.value.add(
                              new BigInteger(value)
                      )
              );
          }
  
          public CustomBigInteger add(int value) {
              return new CustomBigInteger(
                      this.value.add(
                              new BigInteger(
                                      String.valueOf(value)
                              )
                      )
              );
          }
  
          public CustomBigInteger add(CustomBigInteger value) {
              return new CustomBigInteger(
                      this.value.add(
                              value.value
                      )
              );
          }
  
          public CustomBigInteger add(long value) {
              return new CustomBigInteger(
                      this.value.add(
                              new BigInteger(
                                      String.valueOf(value)
                              )
                      )
              );
          }
  
          public CustomBigInteger subtract(String value) {
              return new CustomBigInteger(
                      this.value.subtract(
                              new BigInteger(value)
                      )
              );
          }
  
          public CustomBigInteger subtract(int value) {
              return new CustomBigInteger(
                      this.value.subtract(
                              new BigInteger(
                                      String.valueOf(value)
                              )
                      )
              );
          }
  
          public CustomBigInteger subtract(CustomBigInteger value) {
              return new CustomBigInteger(
                      this.value.subtract(
                              value.value
                      )
              );
          }
  
          public CustomBigInteger subtract(long value) {
              return new CustomBigInteger(
                      this.value.subtract(
                              new BigInteger(
                                      String.valueOf(value)
                              )
                      )
              );
          }
  
          public CustomBigInteger mod(String value) {
              return new CustomBigInteger(
                      this.value.mod(
                              new BigInteger(value)
                      )
              );
          }
  
          public CustomBigInteger mod(int value) {
              return new CustomBigInteger(
                      this.value.mod(
                              new BigInteger(
                                      String.valueOf(value)
                              )
                      )
              );
          }
  
          public CustomBigInteger mod(CustomBigInteger value) {
              return new CustomBigInteger(
                      this.value.mod(
                              value.value
                      )
              );
          }
  
          public CustomBigInteger mod(long value) {
              return new CustomBigInteger(
                      this.value.mod(
                              new BigInteger(
                                      String.valueOf(value)
                              )
                      )
              );
          }
  
          public CustomBigInteger mul(String value) {
              return new CustomBigInteger(
                      this.value.multiply(
                              new BigInteger(value)
                      )
              );
          }
  
          public CustomBigInteger mul(int value) {
              return new CustomBigInteger(
                      this.value.multiply(
                              new BigInteger(
                                      String.valueOf(value)
                              )
                      )
              );
          }
  
          public CustomBigInteger mul(CustomBigInteger value) {
              return new CustomBigInteger(
                      this.value.multiply(
                              value.value
                      )
              );
          }
  
          public CustomBigInteger mul(long value) {
              return new CustomBigInteger(
                      this.value.multiply(
                              new BigInteger(
                                      String.valueOf(value)
                              )
                      )
              );
          }
  
  
          public CustomBigInteger div(String value) {
              return new CustomBigInteger(
                      this.value.divide(
                              new BigInteger(value)
                      )
              );
          }
  
          public CustomBigInteger div(int value) {
              return new CustomBigInteger(
                      this.value.divide(
                              new BigInteger(
                                      String.valueOf(value)
                              )
                      )
              );
          }
  
          public CustomBigInteger div(CustomBigInteger value) {
              return new CustomBigInteger(
                      this.value.divide(
                              value.value
                      )
              );
          }
  
          public CustomBigInteger div(long value) {
              return new CustomBigInteger(
                      this.value.divide(
                              new BigInteger(
                                      String.valueOf(value)
                              )
                      )
              );
          }
      }
  
      private static class FastScanner {
  
          BufferedReader br;
          StringTokenizer st;
  
          private FastScanner() throws FileNotFoundException {
              if (Config.useInputFile)
                  this.br = new BufferedReader(new InputStreamReader(new FileInputStream(Config.inputFile)));
              else
                  this.br = new BufferedReader(new InputStreamReader(System.in));
              this.st = new StringTokenizer("");
          }
  
          String next() {
              while (!st.hasMoreTokens())
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              return st.nextToken();
          }
  
          int nextInt() {
              return Integer.parseInt(next());
          }
  
          int[] readArray(int n) {
              int[] a = new int[n];
              for (int i = 0; i < n; i++) a[i] = nextInt();
              return a;
          }
  
          long nextLong() {
              return Long.parseLong(next());
          }
      }
  
      private static BufferedWriter getWriter() throws Exception {
          if (Config.useOutputFile)
              return getFileWriter();
          return getConsoleWriter();
      }
  
      private static BufferedWriter getFileWriter() throws Exception {
          PrintWriter writer = new PrintWriter(Config.outputFile);
          writer.print("");
          writer.close();
          return new BufferedWriter(new OutputStreamWriter(new FileOutputStream(Config.outputFile)));
      }
  
      private static BufferedWriter getConsoleWriter() {
          return new BufferedWriter(new OutputStreamWriter(System.out));
      }
  }
  