#include using namespace std; using int64 = long long; // Compute x^e mod m in O(log e) int64 modpow(int64 x, int64 e, int64 m) { int64 res = 1 % m; x %= m; while (e > 0) { if (e & 1) res = (__int128)res * x % m; x = (__int128)x * x % m; e >>= 1; } return res; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { int64 A, B, C; cin >> A >> B >> C; // We want the C-th digit after the decimal point of A/B. // Let r = (A * 10^{C-1} mod B). Then the digit is floor(r*10 / B). int64 pow10 = modpow(10, C - 1, B); int64 r = (__int128)A * pow10 % B; int64 digit = (r * 10) / B; cout << digit << "\n"; } return 0; }