#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize(2)
#pragma G++ optimize(2)
using namespace std;
const long long inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const long long N = 1e6 + 10;
int t;
int a[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    int k;
    cin >> k;
    string s;
    int num = 1;
    while (1) {
      s += to_string(num);
      if (k > s.size())
        k -= s.size();
      else {
        cout << s[k - 1] << endl;
        break;
      }
      num++;
    }
  }
  return 0;
}
