#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    int count = 0;
    int i;
    while (n) {
      i = n % 10;
      n /= 10;
      count++;
    }
    if (count == 1)
      count = 1;
    else if (count == 2)
      count = 3;
    else if (count == 3)
      count = 6;
    else
      count = 10;
    printf("%d\n", (i - 1) * 10 + count);
  }
  return 0;
}
