#include <bits/stdc++.h>   using namespace std;   long long nch(long long n) {     long long ans = 0, tmp = 1, k = 1;     while (n) {       ans += min(n, tmp * 9) * k;       n -= min(n, tmp * 9);       tmp *= 10;       k++;     }     return ans;   }   char get(long long n, long long d) {     string s;     stringstream ss;     ss << n;     ss >> s;     return s[d - 1];   }   char kth(long long n) {     long long s = 0, nine = 9, d = 0, len;     for (len = 1;; len++) {       s += nine * len;       d += nine;       if (s >= n) {         s -= nine * len;         d -= nine;         n -= s;         break;       }       nine *= 10;     }     long long diff = ceil((double)n / len);     long long dd = n % len;     if (dd == 0) dd = len;     return get(d + diff, dd);   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long q;     cin >> q;     while (q--) {       long long k, n = 1;       cin >> k;       for (n = 1; nch(n) < k; n++) k -= nch(n);       cout << kth(k) << endl;     }     return 0;   }   