for _ in range(int(input())): a, b, c = map(int, input().split()) d = a % b * pow(10, c, 10 * b) // b print(d % 10)