#include <bits/stdc++.h>
using namespace std;
FILE *stream;
int a[22001], b[22001];
long long f(long long x) {
  string s = to_string(x);
  return s.size();
}
int main() {
  string s;
  long long n, k, ans;
  cin >> n;
  a[0] = b[0] = 0;
  a[1] = 1, b[1] = 1;
  for (long long i = 1; i < 22001 - 1; i++) {
    a[i + 1] = a[i] + f(i + 1);
    b[i + 1] = a[i + 1] + b[i];
  }
  for (long long m = 0; m < n; m++) {
    cin >> k;
    s = "";
    for (long long i = 1; i < 22001; i++) {
      if (k == b[i]) {
        for (long long j = 1; j <= i; j++) {
          s += to_string(j);
        }
        cout << s[k - b[i - 1] - 1] << endl;
      }
      if (k > b[i] && k < b[i + 1]) {
        for (long long j = 1; j <= i + 1; j++) {
          s += to_string(j);
        }
        cout << s[k - b[i] - 1] << endl;
        break;
      }
    }
  }
  return 0;
}
