T = int(input()) mod = 998244353 for _ in range(T): N = int(input()) x, y = [list(i) for i in zip(*[list(map(int, input().split())) for _ in range(N)])] A = [(xi*xi+yi*yi)%mod for xi, yi in zip(x, y)] B = [(xi*xi-yi*yi)%mod for xi, yi in zip(x, y)] C = [(2*xi*yi)%mod for xi, yi in zip(x, y)] D = [pow(a, mod-2, mod) for a in A] E = [b*b*d for b, d in zip(B, D)] F = [b*d for b, d in zip(B, D)] G = [c*c*d for c, d in zip(C, D)] H = [c*d for c, d in zip(C, D)] sd, se, sf, sg, sh = sum(D)%mod, sum(E)%mod, sum(F)%mod, sum(G)%mod, sum(H)%mod print((sd*se-sf*sf + sd*sg-sh*sh)%mod)