#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int anal[(int)1e6];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  int q;
  cin >> q;
  anal[0] = 0;
  for (int i = 1; i < 1e6; i++) {
    vector<int> aa;
    int kek = i;
    while (kek) {
      aa.push_back(kek % 10);
      kek /= 10;
    }
    anal[i] = (int)aa.size();
  }
  while (q--) {
    int k;
    cin >> k;
    int sz = 0;
    int lst = 0;
    int nowsz = 0;
    bool fl = 0;
    while (1) {
      lst++;
      nowsz += anal[lst];
      if (sz + nowsz >= k) {
        string ass;
        int noww = sz;
        for (int i = 1; i <= lst; i++) {
          int kek = i;
          if (noww + anal[i] < k) {
            noww += anal[i];
            continue;
          }
          vector<int> aa;
          while (kek) {
            aa.push_back(kek % 10);
            kek /= 10;
          }
          reverse((aa).begin(), (aa).end());
          cout << aa[k - noww - 1] << '\n';
          fl = 1;
          break;
        }
      }
      if (fl) break;
      sz += nowsz;
    }
  }
  return 0;
}
