#include <bits/stdc++.h>
using namespace std;
long long mod = pow(10, 9) + 7;
int gcdExtended(int a, int b, int* x, int* y);
long long modInverse(int b, int m) {
  int x, y;
  int g = gcdExtended(b, m, &x, &y);
  if (g != 1) return -1;
  return (x % m + m) % m;
}
int gcdExtended(int a, int b, int* x, int* y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
string decimalToBinary(int n) {
  string s = bitset<64>(n).to_string();
  const auto loc1 = s.find('1');
  if (loc1 != string::npos) return s.substr(loc1);
  return "0";
}
int binaryToDecimal(int n) {
  int num = n;
  int dec_value = 0;
  int base = 1;
  int temp = num;
  while (temp) {
    int last_digit = temp % 10;
    temp = temp / 10;
    dec_value += last_digit * base;
    base = base * 2;
  }
  return dec_value;
}
int factorial(int n);
int factorial(int n) {
  unsigned long long ans = 1;
  while (n != 1) {
    ans = ((ans % mod) * (n % mod)) % mod;
    n--;
  }
  return ans;
}
unsigned long long sumbincoef(int N, int k) {
  unsigned long long bincoef = 1, sum = 1;
  int i;
  for (i = 1; i < k; ++i) {
    bincoef = (bincoef * (N - i + 1) / i);
    sum += bincoef;
  }
  return sum;
}
bool is_prime(long long n) {
  if (n == 1) {
    return false;
  }
  long long i = 2;
  while (i * i <= n) {
    if (n % i == 0) {
      return false;
    }
    i += 1;
  }
  return true;
}
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int check(int x, vector<int> a, int n) {
  int county = 0;
  map<int, int> mapa;
  for (int i = 0; i < n; i++) {
    mapa.insert(pair<int, int>(a[i], 0));
  }
  for (int i = 0; i < n; i++) {
    mapa[a[i]]++;
  }
  for (int i = 0; i < a.size(); i++) {
    mapa[a[i]]--;
    if (mapa[abs(a[i] - x)] > 0) {
      county++;
      mapa[abs(a[i] - x)]--;
    }
  }
  return county;
}
class Edge {
 public:
  int sorc, desti, weigh;
};
class Graph {
 public:
  int V, E;
  Edge* edge;
};
Graph* createGraph(int V, int E) {
  Graph* graph = new Graph;
  graph->V = V;
  graph->E = E;
  graph->edge = new Edge[E];
  return graph;
}
class subseting {
 public:
  int parent;
  int rank;
};
int find(subseting subsetsi[], int i) {
  if (subsetsi[i].parent != i)
    subsetsi[i].parent = find(subsetsi, subsetsi[i].parent);
  return subsetsi[i].parent;
}
void Uniony(subseting subsetsi[], int x, int y) {
  int rootx = find(subsetsi, x);
  int rooty = find(subsetsi, y);
  if (subsetsi[rootx].rank < subsetsi[rooty].rank)
    subsetsi[rootx].parent = rooty;
  else if (subsetsi[rootx].rank > subsetsi[rooty].rank)
    subsetsi[rooty].parent = rootx;
  else {
    subsetsi[rooty].parent = rootx;
    subsetsi[rootx].rank++;
  }
}
int Comp(const void* a, const void* b) {
  Edge* a1 = (Edge*)a;
  Edge* b1 = (Edge*)b;
  return a1->weigh < b1->weigh;
}
void MST(Graph* graph) {
  int V = graph->V;
  Edge resulting[V];
  int e = 0;
  int i = 0;
  qsort(graph->edge, graph->E, sizeof(graph->edge[0]), Comp);
  subseting* subsets = new subseting[(V * sizeof(subseting))];
  for (int v = 0; v < V; ++v) {
    subsets[v].parent = v;
    subsets[v].rank = 0;
  }
  while (e < V - 1 && i < graph->E) {
    Edge nextedge = graph->edge[i++];
    int x = find(subsets, nextedge.sorc);
    int y = find(subsets, nextedge.desti);
    if (x != y) {
      resulting[e++] = nextedge;
      Uniony(subsets, x, y);
    }
  }
  long long sum = 0;
  for (i = 0; i < e; i++) {
    sum += resulting[i].weigh;
  }
  cout << sum << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t > 0) {
    string x;
    cin >> x;
    int ans = 0;
    ans += (x[0] - '1') * 10;
    if (x.size() == 1) {
      ans += 1;
    } else if (x.size() == 2) {
      ans += 3;
    } else if (x.size() == 3) {
      ans += 6;
    } else {
      ans += 10;
    }
    cout << ans << endl;
    t--;
  }
}

### Prompt

Please provide a CPP coded solution to the problem described below:

There is a building consisting of 10~000 apartments numbered from 1 to 10~000, inclusive.

Call an apartment boring, if its number consists of the same digit. Examples of boring apartments are 11, 2, 777, 9999 and so on.

Our character is a troublemaker, and he calls the intercoms of all boring apartments, till someone answers the call, in the following order:

  * First he calls all apartments consisting of digit 1, in increasing order (1, 11, 111, 1111). 
  * Next he calls all apartments consisting of digit 2, in increasing order (2, 22, 222, 2222) 
  * And so on. 



The resident of the boring apartment x answers the call, and our character stops calling anyone further.

Our character wants to know how many digits he pressed in total and your task is to help him to count the total number of keypresses.

For example, if the resident of boring apartment 22 answered, then our character called apartments with numbers 1, 11, 111, 1111, 2, 22 and the total number of digits he pressed is 1 + 2 + 3 + 4 + 1 + 2 = 13.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1 ≤ t ≤ 36) — the number of test cases.

The only line of the test case contains one integer x (1 ≤ x ≤ 9999) — the apartment number of the resident who answered the call. It is guaranteed that x consists of the same digit.

Output

For each test case, print the answer: how many digits our character pressed in total.

Example

Input


4
22
9999
1
777


Output


13
90
1
66

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long mod = pow(10, 9) + 7;
int gcdExtended(int a, int b, int* x, int* y);
long long modInverse(int b, int m) {
  int x, y;
  int g = gcdExtended(b, m, &x, &y);
  if (g != 1) return -1;
  return (x % m + m) % m;
}
int gcdExtended(int a, int b, int* x, int* y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
string decimalToBinary(int n) {
  string s = bitset<64>(n).to_string();
  const auto loc1 = s.find('1');
  if (loc1 != string::npos) return s.substr(loc1);
  return "0";
}
int binaryToDecimal(int n) {
  int num = n;
  int dec_value = 0;
  int base = 1;
  int temp = num;
  while (temp) {
    int last_digit = temp % 10;
    temp = temp / 10;
    dec_value += last_digit * base;
    base = base * 2;
  }
  return dec_value;
}
int factorial(int n);
int factorial(int n) {
  unsigned long long ans = 1;
  while (n != 1) {
    ans = ((ans % mod) * (n % mod)) % mod;
    n--;
  }
  return ans;
}
unsigned long long sumbincoef(int N, int k) {
  unsigned long long bincoef = 1, sum = 1;
  int i;
  for (i = 1; i < k; ++i) {
    bincoef = (bincoef * (N - i + 1) / i);
    sum += bincoef;
  }
  return sum;
}
bool is_prime(long long n) {
  if (n == 1) {
    return false;
  }
  long long i = 2;
  while (i * i <= n) {
    if (n % i == 0) {
      return false;
    }
    i += 1;
  }
  return true;
}
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int check(int x, vector<int> a, int n) {
  int county = 0;
  map<int, int> mapa;
  for (int i = 0; i < n; i++) {
    mapa.insert(pair<int, int>(a[i], 0));
  }
  for (int i = 0; i < n; i++) {
    mapa[a[i]]++;
  }
  for (int i = 0; i < a.size(); i++) {
    mapa[a[i]]--;
    if (mapa[abs(a[i] - x)] > 0) {
      county++;
      mapa[abs(a[i] - x)]--;
    }
  }
  return county;
}
class Edge {
 public:
  int sorc, desti, weigh;
};
class Graph {
 public:
  int V, E;
  Edge* edge;
};
Graph* createGraph(int V, int E) {
  Graph* graph = new Graph;
  graph->V = V;
  graph->E = E;
  graph->edge = new Edge[E];
  return graph;
}
class subseting {
 public:
  int parent;
  int rank;
};
int find(subseting subsetsi[], int i) {
  if (subsetsi[i].parent != i)
    subsetsi[i].parent = find(subsetsi, subsetsi[i].parent);
  return subsetsi[i].parent;
}
void Uniony(subseting subsetsi[], int x, int y) {
  int rootx = find(subsetsi, x);
  int rooty = find(subsetsi, y);
  if (subsetsi[rootx].rank < subsetsi[rooty].rank)
    subsetsi[rootx].parent = rooty;
  else if (subsetsi[rootx].rank > subsetsi[rooty].rank)
    subsetsi[rooty].parent = rootx;
  else {
    subsetsi[rooty].parent = rootx;
    subsetsi[rootx].rank++;
  }
}
int Comp(const void* a, const void* b) {
  Edge* a1 = (Edge*)a;
  Edge* b1 = (Edge*)b;
  return a1->weigh < b1->weigh;
}
void MST(Graph* graph) {
  int V = graph->V;
  Edge resulting[V];
  int e = 0;
  int i = 0;
  qsort(graph->edge, graph->E, sizeof(graph->edge[0]), Comp);
  subseting* subsets = new subseting[(V * sizeof(subseting))];
  for (int v = 0; v < V; ++v) {
    subsets[v].parent = v;
    subsets[v].rank = 0;
  }
  while (e < V - 1 && i < graph->E) {
    Edge nextedge = graph->edge[i++];
    int x = find(subsets, nextedge.sorc);
    int y = find(subsets, nextedge.desti);
    if (x != y) {
      resulting[e++] = nextedge;
      Uniony(subsets, x, y);
    }
  }
  long long sum = 0;
  for (i = 0; i < e; i++) {
    sum += resulting[i].weigh;
  }
  cout << sum << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t > 0) {
    string x;
    cin >> x;
    int ans = 0;
    ans += (x[0] - '1') * 10;
    if (x.size() == 1) {
      ans += 1;
    } else if (x.size() == 2) {
      ans += 3;
    } else if (x.size() == 3) {
      ans += 6;
    } else {
      ans += 10;
    }
    cout << ans << endl;
    t--;
  }
}

```