#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void find(long long x) {
  long long base = 1, cur = 9, f = 1;
  while (x - cur * base > 0) {
    x -= cur * base;
    base++;
    cur *= 10;
    f *= 10;
  }
  long long numb = f + (x + base - 1) / base - 1, digit = (x - 1) % base;
  string ans = to_string(numb);
  cout << ans[digit] << endl;
}
void solve() {
  long long k = 0;
  cin >> k;
  long long curlen = 1, toadd = 1, cur = 1, need = 10;
  while (k - curlen > 0) {
    k -= curlen;
    cur++;
    if (cur == need) {
      toadd++;
      need *= 10;
    }
    curlen += toadd;
  }
  find(k);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q = 0;
  cin >> q;
  while (q--) solve();
  return 0;
}
