Finding a longest increasing subsequence of an array is a well known problem. You may also know how to count the number of longest increasing subsequences. But do you know how to count the number of inclusion maximal increasing subsequences?
An increasing subsequence is a non empty list of indices $$$i_1 \lt \dots \lt i_k$$$ such that $$$a[i_1] \lt a[i_2] \lt \dots \lt a[i_k]$$$. Furthermore, it is inclusion maximal if there is no increasing subsequence $$$i^\prime_1 \lt \dots \lt i^\prime_{k^\prime}$$$ with $$$k^\prime \gt k$$$, which contains $$$i_1 \lt \dots \lt i_k$$$ as a subsequence.
The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$), the number of tests.
Each test consists of two lines. The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$). The next line contains $$$n$$$ integers $$$a_i$$$ ($$$1\leq a_i \leq 10^9$$$).
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test output one number, the number of maximal increasing subsequences modulo $$$998\,244\,353$$$.
351 2 3 4 533 1 663 1 5 8 1 3
124
For the first example, there exists one maximal increasing subsequence, the entire array.
In the second example, there are two maximal increasing subsequences, one with array indices 1 and 3 and the other with indices 2 and 3.