#include <bits/stdc++.h>
using namespace std;
long long int t, n, lenn;
long long int last(long long int x) {
  long long int tr = x;
  lenn = 0;
  while (x > 0) {
    tr = x % 10;
    x /= 10;
    ++lenn;
  }
  return tr;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  long long int x, lllll;
  while (t--) {
    cin >> n;
    lllll = last(n);
    if (lenn == 1) {
      x = 1;
    } else if (lenn == 2) {
      x = 3;
    } else if (lenn == 3) {
      x = 6;
    } else {
      x = 10;
    }
    cout << x + 10 * (lllll - 1) << "\n";
  }
  return 0;
}
