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