#include <bits/stdc++.h>
using namespace std;
template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long even = 0, odd = 0, pow = 1;
    long long temp = n;
    while (temp != 0) {
      odd += pow * (temp % 10);
      temp /= 10;
      even += pow * (temp % 10);
      temp /= 10;
      pow *= 10;
    }
    long long pairs1 = (even + 1) / 2, pairs2 = (odd + 1) / 2;
    long long ans = pairs1 * pairs2 * 4 - 2;
    if (even % 2 == 0) {
      ans += pairs2 * 2;
    }
    if (odd % 2 == 0) ans += pairs1 * 2;
    if (even % 2 == 0 && odd % 2 == 0) ans++;
    cout << ans << endl;
  }
}
