#include <bits/stdc++.h>
const int MAXN = 1e6 + 7;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
using namespace std;
const int maxn = 3e5 + 10;
using namespace std;
const double gold = (sqrt(5.0) - 1) / 2;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int n = s.length();
    int ans1 = 0, ans2 = 0;
    for (int i = 0; i < n; i++) {
      if (i & 1) {
        ans1 = ans1 * 10 + s[i] - '0';
      } else
        ans2 = ans2 * 10 + s[i] - '0';
    }
    cout << (ans1 + 1) * (ans2 + 1) - 2 << endl;
  }
  return 0;
}
