AT_abc453_e [ABC453E] Team Division

Description

Divide $ N $ players, player $ 1 $ , player $ 2 $ , $ \ldots $ , player $ N $ , into two (distinguishable) teams $ A $ and $ B $ satisfying all of the following conditions. - Each team consists of at least one player. - Each player belongs to either team $ A $ or team $ B $ , but not both. - The number of players in the team that player $ i $ belongs to is at least $ L_i $ and at most $ R_i $ . Find the number of ways to divide the players satisfying the conditions, and output the count modulo $ 998244353 $ . Two divisions are considered different if there exists a player who belongs to different teams in the two divisions.

Input Format

The input is given from Standard Input in the following format: > $ N $ \ > $ L_1 $ $ R_1 $\ > $ L_2 $ $ R_2 $\ > $ \vdots $\ > $ L_N $ $ R_N $

Output Format

Output the number of valid divisions, modulo $ 998244353 $ .

Explanation/Hint

### Sample Explanation 1 The following two divisions satisfy the conditions. - Player $ 1 $ : Team $ A $ , Player $ 2 $ : Team $ B $ , Player $ 3 $ : Team $ B $ - Player $ 1 $ : Team $ B $ , Player $ 2 $ : Team $ A $ , Player $ 3 $ : Team $ A $ Since $ 2 $ modulo $ 998244353 $ is $ 2 $ , output $ 2 $ . ### Sample Explanation 2 There are $ 30 $ valid divisions. ### Constraints - $ 2\leq N\leq 2\times 10^5 $ - $ 1\leq L_i\leq R_i\leq N-1 $ - All input values are integers.