#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, num;
  cin >> q;
  string s;
  long long cnt = 0, block = 0;
  vector<int> bs;
  for (int i = 1; cnt < 1e9; ++i) {
    s += to_string(i);
    cnt += s.size();
    bs.push_back(cnt);
    ++block;
  }
  for (int i = 0; i < q; ++i) {
    cin >> num;
    auto it = lower_bound(bs.begin(), bs.end(), num);
    num = (it == bs.begin() ? num : num - *(--it)) - 1;
    cout << s[num] << endl;
  }
}
