P7477 "C.E.L.U-02" Partitioning a Multiset
Description
You are given a sequence $v$ of length $n$. Please partition it into two multisets $a$ and $b$. You will partition from left to right, and each number must be put into at least one multiset.
A number $v_i$ can be put into $a$ if and only if all $v_j$ with $j
Input Format
The first line contains two integers $n,m$, as described in the statement.
The next line contains $n$ integers, representing $v$.
The following $m$ lines each contain two integers, representing one relation.
Output Format
Output one integer, the answer.
Explanation/Hint
### Sample Explanation
**Sample Explanation 1**
The following is one valid partition:
|6|2|8|5|7|3|
|:---:|:---:|:---:|:---:|:---:|:---:|
|a|b|b|a|b|a|
**Sample Explanation 2**
The following is one valid partition:
|1|3|4|3|8|2|3|4|5|6|
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|b|b|a|b|a|b|a|a|a|b|
### Constraints
|Test ID|$n$|$m$|
|:---:|:---:|:---:|
|$1\sim2$|$\le10^3$|$0$|
|$3\sim4$|$\le10^3$|$\le10^3$|
|$5\sim6$|$\le2\times10^4$|$0$|
|$7\sim10$|$\le2\times10^4$|$\le2\times10^4$|
For $100\%$ of the testdata, $n,m\le2\times10^4$ and $v_i\le10^9$. It is guaranteed that $u