#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long s[100000], a[100000];
long long Do(long long x, long long d) {
  while (d--) {
    x /= 10;
  }
  return x % 10;
}
int main() {
  int t;
  a[1] = s[1] = 1;
  long long i;
  for (i = 2; i <= 34000; i++) {
    a[i] = a[i - 1] + (long long)log10((double)i) + 1;
    s[i] = s[i - 1] + a[i];
  }
  scanf("%d", &t);
  while (t--) {
    long long n, m;
    scanf("%I64d", &n);
    i = 0;
    while (s[i] < n) i++;
    m = n - s[i - 1];
    i = 0;
    while (m > a[i]) i++;
    int ans = Do(i, a[i] - m);
    printf("%d\n", ans);
  }
  return 0;
}
