#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
using ll = long long;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<ll> a(1), s(1);
  for (ll i = 1;; ++i) {
    ll j = 0;
    for (ll k = i; k; k /= 10, ++j)
      ;
    a.emplace_back(a[i - 1] + j);
    s.emplace_back(s[i - 1] + a[i]);
    if (s[i] > 1e9) break;
  }
  int q;
  cin >> q;
  while (q--) {
    ll x;
    cin >> x;
    ll pos = lower_bound(s.begin(), s.end(), x) - s.begin();
    ll d = x - s[pos - 1];
    for (int i = 1;; ++i) {
      vector<int> num;
      for (int j = i; j; j /= 10) num.emplace_back(j % 10);
      reverse(num.begin(), num.end());
      bool end = 0;
      for (auto j : num) {
        if (!(--d)) {
          cout << j << endl;
          end = 1;
          break;
        }
      }
      if (end) break;
    }
  }
}
