#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
long long tot[N], q, k;
int totalDigits(int n) {
  int ret = 0;
  for (int i = 1; i <= n; i *= 10) ret += (n - i + 1);
  return ret;
}
int main() {
  for (int i = 1; i < N; i++) {
    tot[i] = totalDigits(i) + tot[i - 1];
  }
  int block = -1;
  cin >> q;
  while (q--) {
    cin >> k;
    for (int i = 1; i < N; i++) {
      if (k > tot[i])
        continue;
      else {
        block = i;
        break;
      }
    }
    k -= tot[block - 1];
    int num;
    for (int i = 1; i <= block; i++) {
      int tmp = i;
      int len = 0;
      while (tmp) {
        len++;
        tmp /= 10;
      }
      if (k > len) {
        k -= len;
      } else {
        num = i;
        break;
      }
    }
    string s = "";
    while (num) {
      s += ((num % 10) + '0');
      num /= 10;
    }
    reverse(s.begin(), s.end());
    cout << s[k - 1] << endl;
  }
  return 0;
}
