#include <bits/stdc++.h>
using namespace std;
int k, res;
string s;
int cs(int x) {
  int dem(0);
  while (x != 0) {
    x /= 10;
    dem++;
  }
  return dem;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> k;
    res = 0;
    int ii;
    for (int i = 1; i <= 100000000; ++i) {
      ii = i;
      res += cs(i);
      if (k <= res) break;
      k -= res;
    }
    res = 0;
    for (int i = 1; i <= ii; ++i) {
      res += cs(i);
      if (res >= k) {
        res -= cs(i);
        ii = i;
        break;
      }
    }
    ostringstream convert;
    convert.clear();
    convert << ii;
    s = convert.str();
    cout << s[k - res - 1] << endl;
  }
  return 0;
}
