#include <bits/stdc++.h>
const long double pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const long long int prost = 239;
const long long int btc = 30;
const long double eps = 1e-10;
const int BIG = (int)(1e9 + 239);
const long long MOD = (long long)(1e9 + 7);
const long long int MOD2 = (long long int)MOD * (long long int)MOD;
const int M = (int)(2e5 + 239);
const int N = (int)(2e3 + 239);
const int L = 20;
const int T = (1 << 20);
const int B = 500;
const int X = 1e4 + 239;
const long double EPS = 1e-10;
const long long INF = 1e18;
using namespace std;
long long int findTrailingZeros(long long int n) {
  long long int count = 0;
  for (long long int i = 5; n / i >= 1; i *= 5) count += n / i;
  return count;
}
long long int power(long long int aa, long long int nn) {
  long long int res = 1;
  aa = aa % MOD;
  while (nn > 0) {
    if (nn & 1) res = (res * aa) % MOD;
    nn = nn >> 1;
    aa = (aa * aa) % MOD;
  }
  return res;
}
long long int nCrModp(long long int n, long long int r, long long int p) {
  long long C[r + 1];
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]) % p;
  }
  return C[r];
}
long long int isPrime1(long long int n) {
  if (n <= 1) return 0;
  if (n == 2 || n == 3) return 1;
  if (n % 2 == 0 || n % 3 == 0) return 0;
  for (long long int i = 5; i * i <= n; i += 6)
    if (n % i == 0 || n % (i + 2) == 0) return 0;
  return 1;
}
struct Interval {
  long start, end;
};
bool compareInterval(Interval a, Interval b) {
  if (a.start != b.start)
    return (a.start > b.start);
  else if (a.start == b.start)
    return a.end < b.end;
}
long long int countSquares(long long int a, long long int b) {
  return (floor(sqrt(b)) - ceil(sqrt(a)) + 1);
}
long long int OR(long long int v[], long long int n) {
  long long int ans = v[0];
  for (long long int i = 1; i < n; i++) {
    ans = (ans | v[i]) - v[i];
    if (ans < 0) {
      ans = 0;
      break;
    }
  }
  return ans;
}
long long int block(long long int x) {
  vector<long long int> v;
  long long int sum = 0, count = 0;
  while (x > 0) {
    v.push_back(x % 2);
    if (x % 2 == 1) count++;
    x = x / 2;
  }
  return count;
}
bool cmp(long long a, long long b) {
  return to_string(a) + to_string(b) > to_string(b) + to_string(a);
}
string leftrotate(string s, long long int d) {
  reverse(s.begin(), s.begin() + d);
  reverse(s.begin() + d, s.end());
  reverse(s.begin(), s.end());
  return s;
}
string rightrotate(string s, long long int d) {
  return leftrotate(s, s.length() - d);
}
long long int maxSubArraySum(vector<long long int>& a, long long int size) {
  long long int max_so_far = INT_MIN, max_ending_here = 0;
  for (long long i = 0; i < size; i++) {
    max_ending_here = max(max_ending_here + a[i], a[i]);
    max_so_far = max(max_so_far, max_ending_here);
  }
  return max_so_far;
}
long long int calc(long long int x, long long int y) {
  long long int x1 = (log2(x)) + 1LL, y1 = (log2(y)) + 1LL;
  long long int xx = x, yy = y;
  x = (x << y1);
  y = (y << x1);
  y += xx;
  x += yy;
  return abs(y - x);
}
long long int togglebit(long long int n) {
  if (n == 0) return 1;
  long long int i = n;
  n |= n >> 1;
  n |= n >> 2;
  n |= n >> 4;
  n |= n >> 8;
  n |= n >> 16;
  return i ^ n;
}
long long int XNOR(long long int num1, long long int num2) {
  if (num1 < num2) swap(num1, num2);
  num1 = togglebit(num1);
  return num1 ^ num2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int o = n % 10;
    long long int u = (o - 1) * 10;
    long long int z = log10(n) + 1;
    if (z == 1) {
      cout << u + 1 << endl;
    } else if (z == 2) {
      cout << u + 3 << endl;
    } else if (z == 3)
      cout << u + 6 << endl;
    else
      cout << u + 10 << endl;
  }
}
