# DIST a-b = 2X, a+b = 2Y として定める. mod = 998244353 class BIT: """ 0-indexed. query ... return the sum [0 to m] sum ... return the sum [a to b] sumall ... return the sum [all] add ... 'add' number to element (be careful that it doesn't set a value.) search ... the sum version of bisect.right output ... return the n-th element listout ... return the BIT list """ def query(self, m): res = 0 while m > 0: res = (res+self.bit[m])%mod m -= m&(-m) return res def sum(self, a, b): return (self.query(b)-self.query(a))%mod def sumall(self): bitlen = self.bitlen-1 return self.query(bitlen) def add(self, m, x): m += 1 bitlen = len(self.bit) while m <= bitlen-1: self.bit[m] = (self.bit[m]+x)%mod m += m&(-m) return def output(self, a): return self.query(a+1)-self.query(a) def listout(self): return self.bit def __init__(self, a): self.bitlen = a+1 self.bit = [0]*(a+1) n = int(input()) a = [] sx, sy = 0, 0 gx, gy = 0, 0 for i in range(n): x, y = map(int, input().split()) if i == 0: sx, sy = x + y, x - y elif i == n-1: gx, gy = x + y, x - y else: a.append((x + y, x - y)) #print(sx, sy, gx, gy) if gx <= sx: sx, sy, gx, gy = gx, gy, sx, sy ymin = min(sy, gy) ymax = max(sy, gy) b = [] c = [] def compress(arr): *XS, = set(arr) XS.sort() return {cmp_e:cmp_i for cmp_i, cmp_e in enumerate(XS)} for i in range(n-2): if sx <= a[i][0] <= gx and ymin <= a[i][1] <= ymax: b.append((a[i][0], a[i][1])) c.append(a[i][1]) mode = 0 if sy <= gy: # increase mode = 1 c_cmp = compress(c) # print(c) # print(c_cmp) #print(b) # if b.sort() size = len(b) dp = [0 for i in range(size+1)] dp[0] = 1 bit = BIT(size+1) ans = 0 if mode: bit.add(0, 1) for i in range(size): bit.add(c_cmp[b[i][1]]+1, bit.query(c_cmp[b[i][1]]+2)) print(bit.sumall()) else: bit.add(size, 1) for i in range(size): bit.add(c_cmp[b[i][1]], bit.sum(c_cmp[b[i][1]], size+1)) print(bit.sumall())