#include <bits/stdc++.h>
using namespace std;
int T, n;
int main() {
  ios::sync_with_stdio(0);
  cin >> T;
  while (T--) {
    cin >> n;
    int a = 0, b = 0, t = 1;
    for (int i = 1; i <= 10 && n; i++) {
      if (i & 1)
        a += n % 10 * t;
      else
        b += n % 10 * t, t *= 10;
      n /= 10;
    }
    cout << (a + 1) * (b + 1) - 2 << endl;
  }
  return 0;
}
