#include <bits/stdc++.h>
using namespace std;
int power(int x, int y, int p) {
  int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int digits(int n) {
  int l = 0, ans = 0;
  int x = n;
  while (x > 0) {
    l++;
    x = x / 10;
  }
  for (int i = 1; i < l; i++)
    ans += i * (power(10, i, 100000000007) - power(10, i - 1, 100000000007));
  ans += l * (n - power(10, l - 1, 100000000007) + 1);
  return ans;
}
int len(int n) {
  int l = 0, ans = 0;
  int x = n;
  while (x > 0) {
    l++;
    x = x / 10;
  }
  return l;
}
int solve() {
  int n;
  cin >> n;
  int x = 0, i = 1;
  while (1) {
    if (x >= n) break;
    x += digits(i);
    i++;
  }
  x -= digits(i - 1);
  i--;
  int num;
  for (int j = 1; j < i + 1; j++) {
    if (x + len(j) >= n) {
      num = j;
      break;
    }
    x += len(j);
  }
  x = n - x;
  int reqd = len(num) - x;
  int c = 0;
  while (num > 0) {
    if (c == reqd) return num % 10;
    c++;
    num = num / 10;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) cout << solve() << endl;
  return 0;
}
