#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long inf = 1e9;
int digit(int n) { return n < 10 ? 1 : 1 + digit(n / 10); }
void faltu() {
  long long sum = 0;
  int last = 0;
  int now = 0;
  while (sum <= inf) {
    now++;
    last += digit(now);
    sum += last;
  }
  cout << sum << " " << now << " " << last << "\n";
}
void solve() {
  int k;
  cin >> k;
  int sum = 0;
  int now = 0;
  int last = 0;
  while (sum < k) {
    now++;
    last += digit(now);
    sum += last;
  }
  sum -= last;
  last -= digit(now);
  now--;
  vector<int> vec;
  int sz = 0;
  for (int i = 1; sz <= k - sum; i++) {
    int temp = i;
    vector<int> curr;
    while (temp) {
      curr.push_back(temp % 10);
      temp /= 10;
    }
    reverse(curr.begin(), curr.end());
    for (int x : curr) vec.push_back(x);
    sz += curr.size();
  }
  cout << vec[k - sum - 1] << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
