#include <bits/stdc++.h>
using namespace std;
struct node {
  int val;
  int id;
} date[100100];
bool cmp(node a, node b) {
  if (a.val != b.val) return a.val < b.val;
  return a.id < b.id;
}
vector<int> vec;
vector<int> sam;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string str;
    cin >> str;
    int sign = str[0] - '1';
    int len = str.length();
    len = (len + 1) * len / 2;
    cout << sign * 10 + len << endl;
  }
}
