#include <bits/stdc++.h>   using namespace std;   const unsigned long long hash1 = 201326611;   const double eps = 1e-8;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const int inf = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   const int N = 1e5 + 10;   const int M = 12;   const int dif = 26;   const double PI = acos(-1.0);   inline void Mod(long long& x) {     if (x >= mod) x -= mod;   }   void BinaryBitset(int n) { cout << bitset<sizeof(int) * 4>(n) << endl; }   struct node {     long long l, r, len;   } p[22];   void init() {     p[1].l = 1;     p[1].r = 9;     p[1].len = 9;     for (int i = 2; i <= 18; i++) {       p[i].l = p[i - 1].l * 10;       p[i].r = p[i - 1].r * 10 + 9;       p[i].len = p[i - 1].len * 10;     }   }   int q;   long long k;   bool isOK(long long x, long long k) {     long long ans = 0;     for (int i = 1; i <= 20; i++) {       if (x > p[i].r) {         long long left = x - p[i].r + 1, right = x - p[i].l + 1;         ans += p[i].len * i * (right + left) / 2;       } else {         long long left = 1, right = x - p[i].l + 1;         ans += (right - left + 1) * i * (left + right) / 2;         break;       }       if (ans >= k) return 1;     }     return ans >= k;   }   long long getsum(long long x) {     long long ans = 0;     for (int i = 1; i <= 20; i++) {       if (x > p[i].r) {         long long left = x - p[i].r + 1, right = x - p[i].l + 1;         ans += p[i].len * i * (right + left) / 2;       } else {         long long left = 1, right = x - p[i].l + 1;         ans += (right - left + 1) * i * (left + right) / 2;         return ans;       }     }     return ans;   }   bool isOK2(long long x, long long k) {     long long ans = 0;     for (int i = 1; i <= 20; i++) {       if (x > p[i].r) {         ans += p[i].len * i;       } else {         long long left = 1, right = x - p[i].l + 1;         ans += (right - left + 1) * i;         break;       }       if (ans >= k) return 1;     }     return ans >= k;   }   long long getsum2(long long x) {     long long ans = 0;     for (int i = 1; i <= 20; i++) {       if (x > p[i].r) {         ans += p[i].len * i;       } else {         long long left = 1, right = x - p[i].l + 1;         ans += (right - left + 1) * i;         return ans;       }     }   }   int main() {     init();     scanf( %d , &q);     while (q--) {       scanf( %lld , &k);       long long left = 1, right = 482720320;       while (left <= right) {         long long mid = (left + right) >> 1;         if (isOK(mid, k))           right = mid - 1;         else           left = mid + 1;       }       k -= getsum(left - 1);       left = 1;       right = 1e10;       while (left <= right) {         long long mid = (left + right) >> 1;         if (isOK2(mid, k))           right = mid - 1;         else           left = mid + 1;       }       k -= getsum2(left - 1);       vector<int> ans;       long long x = left;       while (x) {         ans.push_back(x % 10);         x /= 10;       }       int j = 0, h = ans.size() - 1;       while (j <= h) {         swap(ans[j], ans[h]);         j++;         h--;       }       printf( %d n , ans[k - 1]);     }     return 0;   }   