#include #include #include #include using namespace std; #include using mint = atcoder::modint998244353; #include int main() { cin.tie(nullptr), ios::sync_with_stdio(false); int N; cin >> N; vector> A(N); for (auto &[x, y] : A) { long long u, v; cin >> u >> v; x = u + v, y = u - v; } while (true) { if (A.back().second - A.front().second >= 0 and A.back().first - A.front().first >= 0) break; for (auto &[x, y] : A) { swap(x, y); y = -y; } } const auto [xlo, ylo] = A.front(); const auto [xhi, yhi] = A.back(); vector ys{ylo, yhi}, yq; sort(A.begin() + 1, A.end() - 1); for (int i = 1; i < N - 1; ++i) { auto [x, y] = A.at(i); if (xlo <= x and x <= xhi and ylo <= y and y <= yhi) { ys.push_back(y); yq.push_back(y); } } sort(ys.begin(), ys.end()); atcoder::fenwick_tree bit(ys.size()); bit.add(0, 1); mint ret = 1; for (auto y : yq) { int idx = lower_bound(ys.begin(), ys.end(), y) - ys.begin(); auto s = bit.sum(0, idx + 1); ret += s; bit.add(idx, s); } cout << ret.val() << endl; }