#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
T amax(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
template <typename T>
std::istream &operator>>(std::istream &input, std::vector<T> &data) {
  for (T &x : data) input >> x;
  return input;
}
template <typename T>
std::ostream &operator<<(std::ostream &output, const std::pair<T, T> &data) {
  output << "(" << data.first << "," << data.second << ")";
  return output;
}
template <typename T>
std::ostream &operator<<(std::ostream &output, const std::vector<T> &data) {
  for (const T &x : data) output << x << " ";
  return output;
}
long long dp[10000005];
long long cnt[10000005];
void Here_We_Go() {
  long long k;
  cin >> k;
  long long i = 0;
  while (++i) {
    dp[i] = dp[i / 10] + 1;
    cnt[i] = cnt[i - 1] + dp[i];
    if (cnt[i] >= k) break;
    k -= cnt[i];
  }
  i = 0;
  while (++i) {
    if (cnt[i] >= k) {
      k -= cnt[i - 1];
      break;
    }
  }
  vector<long long> v;
  while (i > 0) {
    v.push_back(i % 10);
    i /= 10;
  }
  cout << v[v.size() - k] << '\n';
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long tc = 1;
  cin >> tc;
  for (long long i = 1; i < tc + 1; i++) {
    Here_We_Go();
  }
}
