#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e4 + 2e3;
int n, k, length[MAX], start[MAX];
string str;
int get_length(int number) {
  int len = 0;
  while (number) {
    len++;
    number /= 10;
  }
  return len;
}
void get_start() {
  int sum = 0;
  length[1] = 1;
  start[1] = 1;
  str += '1';
  for (int i = 2; i < MAX; i++) {
    length[i] = length[i - 1] + get_length(i);
    start[i] = start[i - 1] + length[i - 1];
    str += to_string(i);
  }
}
int main() {
  get_start();
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &k);
    int pos = lower_bound(start + 1, start + MAX, k) - start, location;
    if (start[pos] != k) pos--;
    location = k - start[pos];
    printf("%c\n", str[location]);
  }
  return 0;
}
