#include <bits/stdc++.h>
using namespace std;
int MAX = 1e9 + 1;
int mod = 1e9 + 7;
vector<int> p;
void precal() {
  p.push_back(0);
  p.push_back(1);
  int t = 0;
  int b = 0;
  int x = 1;
  while (t < MAX) {
    int num = 0;
    int i = p.size() - 1;
    while (i > 0) {
      num++;
      i /= 10;
    }
    b = b + num;
    t += b;
    p.push_back(t);
  }
  for (int i = 2; i < p.size(); i++) {
    p[i]++;
  }
}
void solve() {
  int n;
  cin >> n;
  int l = upper_bound(p.begin(), p.end(), n) - p.begin() - 1;
  int str = l;
  int t = p[l] - 1;
  for (int j = 1; j < str + 1; j++) {
    int temp = j;
    vector<int> tr;
    while (temp > 0) {
      tr.push_back(temp % 10);
      temp /= 10;
    }
    reverse(tr.begin(), tr.end());
    for (auto &y : tr) {
      t++;
      if (t == n) {
        cout << y << "\n";
        return;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  precal();
  for (int i = 0; i < t; i++) {
    solve();
  }
}
