#include <stdint.h>
#include <iostream>
#include <vector>
using namespace std;
int calc(uint64_t i)
{
uint64_t numerot = 1U;
uint64_t arvot = 1U;
uint64_t raja = 9U;
unsigned int tens;
i--;
while (i / raja >= numerot) {
const uint64_t vanha_raja = raja;
i -= numerot * raja;
numerot++;
arvot *= 10U;
raja *= 10U;
if (raja <= vanha_raja)
break;
}
arvot += i / numerot;
arvot /= pow(10,(numerot - 1) - (i % numerot));
return arvot % 10U;
}
int main()
{
vector<long long> queryvector = {};
long long int query;
cin >> query;
for (long int i = 0; i < query; i++)
{
long long int q;
cin >> q;
queryvector.push_back(q);
}
for (long long kysely : queryvector)
{
cout << calc(kysely) << endl;
}
}