#include #include #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define all(v) begin(v), end(v) using namespace std; using namespace atcoder; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); using mint = modint998244353; using P = pair; int Q; cin >> Q; while (Q--) { int n; cin >> n; vector

z(n); rep(i, n) { int l, r; cin >> l >> r; z[i] = {l, r}; } mint A = 0, B = 0, C = 0, D = 0, E = 0, F = 0, G = 0; rep(i, n) { auto [x, y] = z[i]; mint xxyyI = mint(1) / (x * x + y * y); A += (2 * x * x) * xxyyI; B += (8 * x * y) * xxyyI; C += (2 * y * y) * xxyyI; D += x * x; E += y * y; F += x * x * xxyyI * xxyyI; G += y * y * xxyyI * xxyyI; } mint ans = 0; rep(i, n) { auto [a, b] = z[i]; mint aabbI = mint(1) / (a * a + b * b); ans += -A * (a * a) * aabbI; ans += A * (b * b) * aabbI; ans += -B * a * b * aabbI; ans += C * (a * a) * aabbI; ans += -C * (b * b) * aabbI; ans += D * (a * a) * aabbI * aabbI; ans += D * (b * b) * aabbI * aabbI; ans += E * (a * a) * aabbI * aabbI; ans += E * (b * b) * aabbI * aabbI; ans += F * (a * a); ans += F * (b * b); ans += G * (a * a); ans += G * (b * b); } ans /= 2; cout << ans.val() << endl; } return 0; }