#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll calcp(ll val, ll pos) {
  int id = 1;
  vector<int> G;
  while (val) {
    G.push_back(val % 10);
    val /= 10;
  }
  reverse(G.begin(), G.end());
  for (auto x : G) {
    if (id == pos)
      return x;
    else
      id++;
  }
}
ll calc(ll val) {
  ll p = 9, len = 1, sum = 0;
  while (val > p * len) {
    val -= p * len;
    sum += p;
    p *= 10;
    len++;
  }
  sum += (val / len);
  val %= len;
  if (val == 0) {
    return calcp(sum, len);
  } else {
    return calcp(sum + 1, val);
  }
}
ll calcLOG(ll val) {
  int ret = 0;
  while (val) {
    ret++;
    val /= 10;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  ll q, tmp, len;
  while (cin >> q) {
    while (q--) {
      cin >> tmp;
      len = 0;
      for (int i = 1;; ++i) {
        len += calcLOG(i);
        if (tmp <= len) {
          cout << calc(tmp) << '\n';
          break;
        } else
          tmp -= len;
      }
    }
  }
  return 0;
}
