#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int arr[]{1, 3, 6, 10};
  string s = to_string(n);
  cout << (s[0] - '0' - 1) * 10 + arr[s.size() - 1];
  cout << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tst;
  cin >> tst;
  while (tst--) {
    solve();
  }
}
