#include <bits/stdc++.h>
using namespace std;
mt19937_64 mt_rnd_64(chrono::steady_clock::now().time_since_epoch().count());
long long rnd(long long l, long long r) {
  return (mt_rnd_64() % (r - l + 1)) + l;
}
const int inf = 1e9;
int q, k, l = 2, sz, ns, os;
string t;
string f(int x) {
  string res = "";
  while (x) {
    res += (char)((x % 10) + '0');
    x /= 10;
  }
  reverse(res.begin(), res.end());
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  for (int Q = 0; Q < q; Q++) {
    sz = 1;
    os = 0;
    t = "1";
    l = 2;
    cin >> k;
    int K = k;
    while (sz < k) {
      os = sz;
      t += f(l);
      l++;
      ns = t.size();
      sz += ns;
    }
    k -= os;
    cout << t[k - 1] << '\n';
  }
}
