#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  for (int qq = 1; qq <= q; qq++) {
    int k;
    cin >> k;
    if (k == 1) {
      cout << 1 << endl;
      continue;
    }
    int d[100000];
    d[1] = 1;
    d[2] = 3;
    if (d[2] >= k) {
      k = k - d[1];
    } else if (d[1] < k) {
      for (int i = 3; i <= k; i++) {
        d[i] = d[i - 1] + d[i - 1] - d[i - 2] + (int)log10(i) + 1;
        if (d[i] >= k) {
          k = k - d[i - 1];
          break;
        }
      }
    }
    int p[100000];
    int h = 0;
    p[1] = 1;
    if (k > p[1]) {
      for (int i = 2; i <= k; i++) {
        p[i] = p[i - 1] + 1 + (int)log10(i);
        if (p[i] >= k) {
          k = k - p[i - 1];
          h = i;
          break;
        }
      }
    }
    if (h == 0) {
      h++;
    }
    string s = to_string(h);
    cout << s[k - 1] << endl;
  }
  return 0;
}
