#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 7;
const long long int mod = 1e9 + 7;
void solve1() {
  string a;
  cin >> a;
  cout << (a[0] - '0' - 1) * 10 + (a.size() * (a.size() + 1)) / 2 << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  long long int cghf = 1;
  cin >> cghf;
  while (cghf--) {
    solve1();
  }
}
