import sys input = sys.stdin.readline N = int(input()) mod = 998244353 a = [] for _ in range(N): x, y = map(int, input().split()) a.append((x + y, x - y)) #print(a) def compress(init_val): t = sorted(set(init_val)) d = dict([[t[i], i] for i in range(len(t))]) res = [0] * len(init_val) for i in range(len(init_val)): res[i] = d[init_val[i]] return res def compress2(init_val): xs = compress([init_val[i][0] for i in range(len(init_val))]) ys = compress([init_val[i][1] for i in range(len(init_val))]) return [(xs[i], ys[i] + 1) for i in range(len(init_val))] a = compress2(a) s = min(a[0], a[-1]) t = max(a[0], a[-1]) a = sorted(a[1: -1]) class BIT: def __init__(self, n): self.n = n self.data = [0] * (n + 1) self.el = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.data[i] s %= mod i -= i & -i return s def add(self, i, x): self.el[i] += x self.el[i] %= mod while i <= self.n: self.data[i] += x self.data[i] %= mod i += i & -i def get(self, i, j = None): if j is None: return self.el[i] return (self.sum(j) - self.sum(i)) % mod def lowerbound(self, s): x = 0 y = 0 for i in range(self.n.bit_length(), -1, -1): k = x + (1 << i) if k <= self.n and (y + self.data[k] < s): y += self.data[k] x += 1 << i return x + 1 fwk = BIT(N) fwk.add(s[1], 1) #print(s, a, t) if s[1] <= t[1]: for x, y in a: if x in range(s[0], t[0] + 1) and y in range(s[1], t[1] + 1): fwk.add(y, fwk.sum(y)) print(fwk.sum(t[1])) else: for x, y in a: if x in range(s[0], t[0] + 1) and y in range(t[1], s[1] + 1): fwk.add(y, fwk.get(y - 1, N)) print(fwk.get(t[1] - 1, N))