The Legendary Huron is planning the construction of $$$n$$$ skyscrapers on a major street in Huronland that runs from west to east. The final skyline will be an array of positive integers $$$A = [a_1, a_2, \dots, a_n]$$$, where $$$a_i$$$ is the height of the $$$i$$$-th skyscraper from the west. The order of construction and the heights are yet to be decided. For safety reasons, only one skyscraper can be built at a time.
After all skyscrapers are completed, the Tourism Office will promote each one using a panoramic photo. For each skyscraper $$$i$$$, the office selects the longest contiguous segment of skyscrapers that includes $$$i$$$, such that the maximum height in the segment is $$$a_i$$$, and takes a photo of such segment. A photo is considered successful if:
The Tourism Office asks the Legendary Huron to assign positive heights and a construction order so that all $$$n$$$ photos are successful. Two plans are different if the heights or construction order differ. Determine the number of such valid plans, modulo $$$998244353$$$.
The first line contains $$$n$$$ ($$$1 \leq n \leq 5 \cdot 10^5$$$).
Then $$$n$$$ lines follows, where the $$$(i+1)$$$-th line contains two integers $$$l_i$$$ and $$$r_i$$$ ($$$0 \leq l_i \leq r_i \leq 10^9$$$).
Print the answer modulo $$$998244353$$$.
11 10
10
10 0
0
21 45 7
24
31 12 23 3
6
| Name |
|---|


