#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
struct fast_ios {
  fast_ios() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
  }
} fast_ios_;
ll calc(ll n) {
  ll ret = 0;
  ll i = 1;
  ll pv = 9;
  while (n > pv * i) {
    n -= pv * i;
    ret += pv;
    ++i;
    pv *= 10;
  }
  ret += (n - 1) / i + 1;
  n -= (n - 1) / i * i;
  ll t = 1;
  while (ret >= t) {
    t *= 10;
  }
  while (n--) {
    t /= 10;
  }
  return (ret / t) % 10;
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    int k;
    cin >> k;
    int n = 1, cn = 0;
    while (true) {
      int tn = n, tc = 0;
      while (tn) {
        ++tc;
        tn /= 10;
      }
      ++n;
      cn += tc;
      if (k <= cn) break;
      k -= cn;
    }
    cout << calc(k) << '\n';
  }
  return 0;
}
