#include <bits/stdc++.h>
using namespace std;
const int MAX = 98070;
int t;
long long k;
int main() {
  ios::sync_with_stdio(0);
  string a;
  for (int i = 1; i < MAX; i++) a += to_string(i);
  cin >> t;
  while (t--) {
    cin >> k;
    long long l = 0, pv = 0, p10 = 10, len = 1;
    while (1729) {
      l++;
      if (l == p10) len++, p10 *= 10;
      pv += len;
      if (k > pv)
        k -= pv;
      else {
        cout << a[k - 1] << "\n";
        break;
      }
    }
  }
}
