#include <bits/stdc++.h>
using namespace std;
int len(long long num) {
  int cnt = 0;
  while (num > 0) {
    num /= 10;
    cnt++;
  }
  return cnt;
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    int k;
    cin >> k;
    long long blocklen = 1, num = 1;
    while (k > blocklen) {
      k -= blocklen;
      num++;
      blocklen += len(num);
    }
    long long temp = 1;
    while (k > len(temp)) {
      k -= len(temp);
      temp++;
    }
    auto s = to_string(temp);
    cout << s[k - 1] << '\n';
  }
}
