#include <bits/stdc++.h>
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    cout << (s[0] - '0' - 1) * 10 + (s.size() * (s.size() + 1)) / 2 << endl;
  }
}
