#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, last = 0, count = 0, sum, sum1;
    cin >> n;
    while (n >= 10) {
      last = n / 10;
      n = n / 10;
      count += 1;
    }
    if (count + 1 == 1)
      sum1 = 1;
    else if (count + 1 == 2)
      sum1 = 3;
    else if (count + 1 == 3)
      sum1 = 6;
    else if (count + 1 == 4)
      sum1 = 10;
    sum = (last - 1) * 10 + sum1;
    if (n > 10)
      cout << sum << endl;
    else {
      last = n;
      sum = (last - 1) * 10 + sum1;
      cout << sum << endl;
    }
  }
}
