#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll lim = 22000;
string all;
vector<ll> blockend(lim);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  for (ll i = 1; i < lim; i++) {
    all += to_string(i);
    blockend[i] = blockend[i - 1] + (int)(all).size();
  }
  ll q;
  cin >> q;
  for (ll i = 0; i < q; i++) {
    ll k;
    cin >> k;
    k--;
    auto it = prev(upper_bound(begin(blockend), end(blockend), k));
    cout << all[k - *it] << endl;
  }
}
