#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& in, vector<T>& a) {
  for (int i = 0; i < a.size(); i++) in >> a[i];
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T>& a) {
  for (int i = 0; i < a.size(); i++) out << a[i];
  return out;
}
template <typename T, typename E>
istream& operator>>(istream& in, pair<T, E>& a) {
  in >> a.first >> a.second;
  return in;
}
int gcd(int a, int b) {
  int c = 1;
  while (b) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
int dx[8] = {-2, -1, 1, 2, 2, 1, -1, -2};
int dy[8] = {1, 2, 2, 1, -1, -2, -2, -1};
vector<int> nx = {0, 9, 189, 2889, 38889, 488889, 5888889, 68888889};
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  int q;
  cin >> q;
  while (q--) {
    long long n, j, i, k;
    cin >> n;
    j = 1;
    i = 1;
    while (n > i) {
      j++, k = j, n -= i;
      while (k) {
        k /= 10;
        ++i;
      }
    }
    i = 1, j = 1;
    while (n > i) {
      j++;
      k = j;
      n -= i;
      i = 0;
      while (k) {
        ++i;
        k /= 10;
      }
    }
    for (k = 0; k < i - n; ++k) j /= 10;
    cout << j % 10 << '\n';
  }
  q = q;
}
