def main(): mod = 998244353 # mod 998244353のFenwickTree class FenwickTreeMod: def __init__(self, n): self.n = n self.data = [0] * (n + 1) def add(self, k, x): k += 1 while k <= self.n: self.data[k] += x self.data[k] %= mod k += k & -k def sum(self, k): res = 0 while k: res += self.data[k] res %= mod k -= k & -k return res # 座標圧縮 def compress(a): mem = {} for idx, elm in enumerate(sorted(set(a))): mem[elm] = idx return mem # 入力 N = int(input()) X, Y = [None] * N, [None] * N for i in range(N): a, b = map(int, input().split()) X[i], Y[i] = a + b, a - b # 座標を反転しておく if X[0] > X[-1]: for i in range(N): X[i] = -X[i] if Y[0] > Y[-1]: for i in range(N): Y[i] = -Y[i] # y座標を圧縮 mem = compress(Y) for i in range(N): Y[i] = mem[Y[i]] # x, y座標が範囲内の点のみソート points = [(i, j) for i, j in zip(X, Y) if X[0] <= i <= X[-1] and Y[0] <= j <= Y[-1]] # DP ft = FenwickTreeMod(len(mem)) ft.add(Y[0], 1) for i in range(1, len(points) - 1): ft.add(points[i][1], ft.sum(points[i][1] + 1)) # 出力 print(ft.sum(Y[-1] + 1)) main()