#include <bits/stdc++.h>
using namespace std;
void solver() {
  string n;
  cin >> n;
  int total = 0;
  int fix = 10;
  int temp = (int)(n[0] - '0') % 10;
  total += fix * (temp - 1);
  temp = n.length();
  total += (temp * (temp + 1)) / 2;
  cout << total << endl;
}
int main() {
  int t;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solver();
  }
  return 0;
}
