#include <bits/stdc++.h>
using namespace std;
const long long logN = 20;
const long long M = 1000000007;
const long long INF = 1e12;
const long long N = 100005;
long long sum(long long n) {
  if (n < 0) return 0;
  return n * (n + 1) / 2;
}
long long find(long long t) {
  long long cnt = 0;
  long long q = 9;
  long long p = 1;
  while (t > 0) {
    cnt += p * (sum(t) - sum(t - q));
    p++;
    t -= q;
    q *= 10;
  }
  return cnt;
}
long long get(long long n) {
  long long p = 9;
  long long q = 10;
  long long r = 1;
  long long cnt = 0;
  while (q - 1 < n) {
    cnt += r * p;
    p = p * 10;
    q = q * 10;
    r++;
  }
  cnt += (n - q / 10 + 1) * r;
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long no;
  cin >> no;
  long long n = 0;
  while (no--) {
    cin >> n;
    long long l = 1, r = 2000000000;
    while (r > l) {
      long long m = (l + r) / 2;
      long long cnt = find(m);
      if (cnt < n)
        l = m + 1;
      else
        r = m;
    }
    long long rem = n - find(l - 1);
    long long p = 1;
    r = l;
    l = 0;
    while (r > l) {
      long long m = (l + r) / 2;
      long long cnt = get(m);
      if (cnt < rem)
        l = m + 1;
      else
        r = m;
    }
    long long f = rem - get(l - 1);
    string s;
    while (l) s += ('0' + l % 10), l = l / 10;
    reverse(s.begin(), s.end());
    cout << s[f - 1] << "\n";
  }
  return 0;
}
