#include <bits/stdc++.h>
using namespace std;
string seq;
vector<int> ele, diff;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int cur = 1;
  vector<tuple<int, int> > lengths;
  int total = 0;
  while (total <= 1e9) {
    int temp = cur;
    vector<char> digits;
    while (temp) {
      digits.push_back((temp % 10) + '0');
      temp /= 10;
    }
    for (int i = digits.size() - 1; i >= 0; --i) seq += digits[i];
    total += seq.size();
    lengths.emplace_back(total, seq.size() - 1);
    ++cur;
  }
  int q, k;
  int length, idx;
  cin >> q;
  while (q--) {
    cin >> k;
    for (auto ele : lengths) {
      tie(length, idx) = ele;
      if (length >= k) {
        cout << seq[idx - (length - k)] << "\n";
        break;
      }
    }
  }
  return 0;
}
