| Codeforces Round 1105 (Div. 1) |
|---|
| Finished |
Gold14526 is a painter. He can paint with $$$n$$$ colors, numbered $$$1, 2, \ldots, n$$$. Color $$$i$$$ has a constraint interval $$$[l_i, r_i]$$$.
A work is defined as a rooted tree $$$T=(V,E)$$$ where every edge is colored (with one of the $$$n$$$ colors). A work is called colorful if the following conditions are satisfied:
Two works $$$T=(V,E)$$$ and $$$T'=(V',E')$$$ are defined as isomorphic if and only if the following two conditions are met:
Gold14526 wants to know the maximum number of colorful works he can choose such that the works are pairwise non-isomorphic. Output the answer modulo $$$\bf2$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first line of each test case contains an integer $$$n$$$ ($$$1\le n\le 2\cdot 10^6$$$) — denoting the number of colors.
The following $$$n$$$ lines each contain two integers, the $$$i$$$ -th of them $$$l_i$$$ and $$$r_i$$$ ($$$0\le l_i\le r_i\le 2\cdot 10^5$$$, $$$r_i\ge 1$$$) — denoting the constraint interval of the $$$i$$$ -th color.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot 10^6$$$.
Let $$$m=\max_{i=1}^n r_i$$$. Then it is guaranteed that the sum of $$$m$$$ over all test cases does not exceed $$$2\cdot 10^5$$$.
For each test case, output $$$0$$$ or $$$1$$$, representing the maximum number of works that can be chosen modulo $$$2$$$.
420 10 121 11 130 20 10 131 21 11 1
1011
In the first test case, the constraints for both colors are $$$[0, 1]$$$. This means on any simple path from the root, there can be at most $$$1$$$ edge of color $$$1$$$ and at most $$$1$$$ edge of color $$$2$$$. There are exactly $$$9$$$ valid pairwise non-isomorphic trees:
In the second test case, the constraints for both colors are $$$[1, 1]$$$. Every valid tree must satisfy the maximum count of each color on the paths to be exactly $$$1$$$. Therefore, the tree must contain at least one edge of color $$$1$$$ and at least one edge of color $$$2$$$. There are exactly $$$6$$$ valid trees:
| Name |
|---|


