I=input P=998244353 for t in range(int(I())): A,B,C=map(int,I().split()) print(((A*A+B*B)*pow(C,-2,P)+1)%P)