#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  std::ios::sync_with_stdio(false);
  long long int n;
  cin >> n;
  long long int arr[n][3];
  string s = "1";
  for (int i = 0; i < n; i++) {
    cin >> arr[i][0];
    arr[i][2] = 0;
  }
  long long int len = 1;
  long long int num = 2;
  int cnt = 0;
  while (cnt < n) {
    for (int i = 0; i < n; i++) {
      if (arr[i][2] == 0 && arr[i][0] <= len) {
        arr[i][1] = s[arr[i][0] - 1] - '0';
        arr[i][2] = 1;
        cnt++;
      } else if (arr[i][2] == 0) {
        arr[i][0] -= len;
      }
    }
    s += to_string(num);
    len = s.length();
    num++;
  }
  for (int i = 0; i < n; i++) {
    cout << arr[i][1] << '\n';
  }
  return 0;
}
