MOD = 998244353 class Bit: def __init__(self, n): self.size = n self.n0 = 1 << (n.bit_length() - 1) self.tree = [0] * (n + 1) def range_sum(self, l, r): return self.sum(r - 1) - self.sum(l - 1) def sum(self, i): i += 1 s = 0 while i > 0: s += self.tree[i] s %= MOD i -= i & -i return s def get(self, i): return self.sum(i) - self.sum(i - 1) def add(self, i, x): i += 1 while i <= self.size: self.tree[i] += x self.tree[i] %= MOD i += i & -i def lower_bound(self, x): pos = 0 plus = self.n0 tot = 0 while plus > 0: if pos + plus <= self.size and self.tree[pos + plus] < x: x -= self.tree[pos + plus] pos += plus plus //= 2 return pos n = int(input()) xy = [] for _ in range(n): x, y = map(int, input().split()) xy.append((x - y, x + y)) if xy[0][0] < xy[-1][0]: px = 1 else: px = -1 if xy[0][1] < xy[-1][1]: py = 1 else: py = -1 xy = [(x * px, y * py) for x, y in xy] sx, sy = xy[0] gx, gy = xy[-1] xy = xy[1:-1] lst = [] se_y = {sy, gy} for x, y in xy: if sx <= x <= gx and sy <= y <= gy: lst.append((x, y)) se_y.add(y) lst.sort(key = lambda x:(x[0], x[1])) dic = {y:i for i, y in enumerate(sorted(se_y))} l = len(dic) sy = dic[sy] gy = dic[gy] bit = Bit(l) bit.add(sy, 1) for _, y in lst: y = dic[y] bit.add(y, bit.sum(y)) ans = bit.sum(gy) % MOD print(ans)