#include <bits/stdc++.h>
using namespace std;
int dx[] = {-2, -1, 1, 2, -2, -1, 1, 2};
int dy[] = {-1, -2, -2, -1, 1, 2, 2, 1};
template <class T>
inline T biton(T n, T pos) {
  return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
  return n & ~((T)1 << pos);
}
template <class T>
inline T ison(T n, T pos) {
  return (bool)(n & ((T)1 << pos));
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
template <class T>
inline T bigmod(T p, T e, T m) {
  T ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % m;
    p = (p * p) % m;
  }
  return (T)ret;
};
long long getDigit(long long i) {
  int res = 0;
  while (i) {
    i = i / 10ll;
    res++;
  }
  return res;
}
void solve() {
  long long n;
  cin >> n;
  long long sum = 0;
  long long i = 1;
  long long tdigit = 0;
  long long last = 0;
  while (true) {
    long long digit = getDigit(i);
    tdigit += digit;
    sum += tdigit;
    if (sum >= n) {
      break;
    }
    last = sum;
    i++;
  }
  long long st = 1;
  while (true) {
    long long temp = st;
    string str = to_string(temp);
    for (int i = 0; i < str.size(); i++) {
      last++;
      if (last == n) {
        cout << str[i] << endl;
        ;
        return;
      }
    }
    st++;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(10);
  cout.tie(nullptr);
  cin.tie(nullptr);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
