#include <bits/stdc++.h>
using namespace std;
void solve() {
  string n;
  cin >> n;
  long long x1 = 0, x2 = 0;
  for (long long i = 0; i < n.length(); i += 2) x1 = x1 * 10 + (n[i] - '0');
  for (long long i = 1; i < n.length(); i += 2) x2 = x2 * 10 + (n[i] - '0');
  long long ans = (x1 + 1LL) * (x2 + 1LL) - 2LL;
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1, x = 0;
  cin >> t;
  while (t--) {
    x++;
    solve();
  }
}
