#include <bits/stdc++.h>
using namespace std;
int q;
long long int k;
long long int get(long long int r) { return r * (r + 1) / 2; }
long long int sum(long long int r, int need) {
  long long int sum = 0;
  long long int pw = 1;
  long long int pre = 0;
  for (int len = 1;; len++) {
    if (pw * 10 - 1 < r) {
      long long int cnt = pw * 10 - pw;
      if (need) {
        sum += pre * cnt + get(cnt) * len;
        pre += cnt * len;
      } else
        sum += cnt * len;
    } else {
      long long int cnt = r - pw + 1;
      if (need) {
        sum += pre * cnt + get(cnt) * len;
        pre += cnt * len;
      } else
        sum += cnt * len;
      break;
    }
    pw *= 10;
  }
  return sum;
}
int main() {
  scanf("%d", &q);
  for (; q; q--) {
    scanf("%lld", &k);
    --k;
    long long int l = 1, r = 1e9;
    long long int res = -1;
    while (l <= r) {
      long long int mid = (l + r) / 2;
      if (sum(mid, 1) > k) {
        res = mid;
        r = mid - 1;
      } else
        l = mid + 1;
    }
    k -= sum(res - 1, 1);
    l = 1, r = res;
    long long int num = -1;
    while (l <= r) {
      long long int mid = (l + r) / 2;
      if (sum(mid, 0) > k) {
        num = mid;
        r = mid - 1;
      } else
        l = mid + 1;
    }
    printf("%c\n", to_string(num)[k - sum(num - 1, 0)]);
  }
  return 0;
}
