#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long p[100];
const int nax = 1e5;
long long sum[nax];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  p[0] = 1;
  for (int i = 1; i <= 18; i++) p[i] = p[i - 1] * 10LL;
  for (int i = 1; i < nax; i++) {
    long long x = floor(log10(10 * i));
    sum[i] = (i + 1) * x - (p[x] - 1) / 9;
    sum[i] += sum[i - 1];
  }
  string s;
  for (int i = 1; i <= nax; i++) {
    s += to_string(i);
    if (s.size() >= (int)1e5) break;
  }
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long lo = 0, hi = nax - 1, ans = 0;
    while (lo <= hi) {
      long long md = (lo + hi) / 2;
      long long cur = sum[md];
      if (cur < n) {
        ans = md;
        lo = md + 1;
      } else
        hi = md - 1;
    }
    n -= sum[ans];
    cout << s[n - 1] << '\n';
  }
}
