#include <bits/stdc++.h>
using namespace std;
int a[15];
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = getchar();
  return x * f;
}
int main() {
  int t = read();
  while (t--) {
    int n = read(), x = 0, y = 0, s = 0, xx = 0, yy = 0;
    while (n) a[++s] = n % 10, n /= 10;
    for (int i = s; i; i--)
      if (i & 1)
        x = x * 10 + a[i];
      else
        y = y * 10 + a[i];
    printf("%d\n", (x + 1) * (y + 1) - 2);
  }
  return 0;
}
