#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int q;
  cin >> q;
  vector<ll> k;
  k.reserve(q);
  for (int i = 0; i < q; ++i) {
    ll temp;
    cin >> temp;
    k.push_back(temp);
    assert(temp >= 1);
  }
  vector<ll> res(q, -1);
  int marked_count = 0;
  string cur;
  for (ll i = 1; marked_count < q; ++i) {
    string temp = to_string(i);
    cur += temp;
    for (size_t j = 0; j < k.size(); ++j) {
      if (res.at(j) >= 0) continue;
      assert(res.at(j) == -1);
      if (k.at(j) - 1 < cur.size()) {
        res.at(j) = cur.at(k.at(j) - 1);
        ++marked_count;
      } else {
        k.at(j) -= cur.size();
      }
    }
  }
  for (ll i : res) {
    cout << i - '0' << endl;
  }
  return 0;
}
