#include <bits/stdc++.h>
using namespace std;
int q;
int main() {
  cin >> q;
  while (q--) {
    long long k;
    cin >> k;
    long long i = 1, j = 1, ans = 0;
    while (k > i) {
      k -= i;
      ++j;
      long long now = j;
      while (now) {
        ++i;
        now /= 10;
      }
    }
    i = 1;
    j = 1;
    while (k > i) {
      k -= i;
      ++j;
      long long now = j;
      i = 0;
      while (now) {
        ++i;
        now /= 10;
      }
    }
    for (int l = 0; l < i - k; ++l) {
      j /= 10;
    }
    cout << j % 10 << endl;
  }
  return 0;
}
