#include <bits/stdc++.h>
using namespace std;
int l(int x) {
  int ans = 0;
  while (x > 0) {
    x /= 10;
    ans++;
  }
  return ans;
}
int main() {
  int q;
  long long k[1000], b[50000];
  b[1] = 1;
  for (int i = 2; i < 50000; i++) {
    b[i] = b[i - 1] + l(i);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> k[i];
  }
  for (int i = 0; i < q; i++) {
    int x = 0;
    for (int j = 1; j < 50000; j++) {
      if (b[j] < k[i]) {
        k[i] -= b[j];
      }
    }
    for (int j = 1;; j++) {
      if (l(j) < k[i]) {
        k[i] -= l(j);
      } else {
        int le = l(j);
        le = le - k[i];
        while (le--) {
          j /= 10;
        }
        cout << j % 10 << endl;
        break;
      }
    }
  }
  return 0;
}
