#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int sum = 0;
    sum = 10 * (s[0] - '0' - 1);
    if (s.size() == 1) {
      sum += 1;
    }
    if (s.size() == 2) {
      sum += 3;
    }
    if (s.size() == 3) {
      sum += 6;
    }
    if (s.size() == 4) {
      sum += 10;
    }
    cout << sum << endl;
  }
}
