#include <bits/stdc++.h>
using namespace std;
long long int binary_expo(long long int x, long long int n) {
  if (n == 0) return 1;
  long long int res = binary_expo(x, n / 2);
  if (n & 1) return res * res * x;
  return res * res;
}
long long int factorial(long long int n) {
  if (n > 1)
    return n * factorial(n - 1);
  else
    return 1;
}
long long int msb_b(long long int n) {
  if (n == 0) return 0;
  long long int msb = 0;
  n >>= 1;
  while (n != 0) {
    n >>= 1;
    msb++;
  }
  return msb;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long int n = s.size();
    long long int r = s[0] - '0';
    long long int ans = 10 * (r - 1);
    if (n == 1)
      cout << ans + 1 << endl;
    else if (n == 2)
      cout << ans + 1 + 2 << endl;
    else if (n == 3)
      cout << ans + 1 + 2 + 3 << endl;
    else
      cout << ans + 1 + 2 + 3 + 4 << endl;
  }
  return 0;
}
