#include <bits/stdc++.h>
using namespace std;
long long int ara[1000000];
int wow[7 * 22000];
void make_wow(int x) {
  int xx;
  int l;
  int k = 1;
  stack<int> s;
  for (int i = 1; i <= x; i++) {
    xx = i;
    while (xx != 0) {
      l = xx % 10;
      xx /= 10;
      s.push(l);
    }
    while (!s.empty()) {
      wow[k++] = s.top();
      s.pop();
    }
  }
}
int find_block(int x, int b) {
  for (int i = 1; i <= b; i++) {
    if (ara[i] >= x) return i - 1;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> q;
  int k = 1;
  int i = 1;
  int b = 1;
  long long int sum = 0, x, lb;
  while (ara[b - 1] <= 1000000000) {
    sum += log10(i++) + 1;
    ara[b] = ara[b - 1] + sum;
    b++;
  }
  make_wow(b);
  while (q--) {
    cin >> x;
    cout << wow[x - ara[find_block(x, b)]] << endl;
  }
  return 0;
}
