import sys input = sys.stdin.readline from bisect import * from copy import deepcopy def compress(lst): """ B: lstを座圧したリスト D: 元の値からindex取得する辞書 """ B = [] D = dict() vals = deepcopy(lst) vals = list(set(vals)) vals.sort() for i in range(len(lst)): ind = bisect_left(vals, lst[i]) B.append(ind) for i in range(len(B)): D[lst[i]] = B[i] return B, D, vals N = int(input()) B, C = [0] * N, [0] * N for i in range(N): B[i], C[i] = map(int, input().split()) B[i] -= 1 A, _, vals = compress(B + C) B2, C2 = A[:N], A[N:] M = len(vals) L1, L2 = [0] * M, [0] * M mod = 998244353 for i in range(N): inv1 = pow(C[i] - B[i], mod - 2, mod) inv2 = pow((C[i] - B[i]) ** 2, mod - 2, mod) L1[B2[i]] += inv1 L1[C2[i]] -= inv1 L2[B2[i]] += inv2 L2[C2[i]] -= inv2 Ac1 = [0] * M Ac2 = [0] * M Ac1[0] = L1[0] Ac2[0] = L2[0] for i in range(M - 1): Ac1[i + 1] = Ac1[i] + L1[i + 1] Ac2[i + 1] = Ac2[i] + L2[i + 1] ans1 = N * (N - 1)//2 inv = pow(2, mod - 2, mod) for i in range(M - 1): ans1 -= (vals[i + 1] - vals[i]) * (Ac1[i] ** 2 - Ac2[i]) * inv ans1 %= mod for i in range(1, N + 1): ans1 *= i ans1 %= mod print(ans1 * inv % mod)