#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int arr[4] = {1, 3, 6, 10};
  while (t--) {
    int x;
    cin >> x;
    int num1 = x % 10;
    int num2 = 0;
    while (x != 0) {
      x = x / 10;
      num2++;
    }
    cout << (num1 - 1) * 10 + arr[num2 - 1] << "\n";
  }
  return 0;
}
