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