#include <bits/stdc++.h>
using namespace std;
int main() {
  int l;
  cin >> l;
  while (l--) {
    int num;
    cin >> num;
    int ans = num % 10;
    if (num <= 9) {
      cout << (num - 1) * 10 + 1 << endl;
    } else if (ans >= 1) {
      int j = (num - ans) / 10;
      if (j > 100) {
        cout << (ans - 1) * 10 + 10 << endl;
      } else if (j > 10 && j < 100) {
        cout << (ans - 1) * 10 + 6 << endl;
      } else if (j >= 1 && j < 10) {
        cout << (ans - 1) * 10 + 3 << endl;
      }
    }
  }
  return 0;
}
