| Codeforces Round 1074 (Div. 4) |
|---|
| Finished |
You are given $$$n$$$ arrays $$$a_1, a_2, \ldots, a_n$$$.
The following operation is performed exactly once:
Evaluate the sum of the values of all possible distinct independent operations. Two operations are distinct if the ordered triple of integers $$$(i,j,k)$$$ is different.
$$$\operatorname{MEX}(a)$$$ is defined as the smallest non-negative integer that is not present in the array. For example, $$$\operatorname{MEX}([1, 2, 0, 5])$$$ is $$$3$$$, and $$$\operatorname{MEX}([1, 2, 4, 9])$$$ is $$$0$$$.
The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases.
The first line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the number of arrays.
The next $$$n$$$ lines start with $$$l_i$$$ ($$$1 \le l_i \le 10^5$$$) — the length of the $$$i$$$th array — then contain $$$l_i$$$ integers $$$a_1, a_2, \ldots, a_{l_i}$$$ ($$$0 \le a_{i_j} \le 10^6$$$) — the array $$$a_i$$$.
It is guaranteed that the sum of $$$l_i$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.
For each test case, output the sum of the values of all possible distinct operations.
621 02 1 231 12 2 33 4 5 654 1 7 8 102 5 62 0 72 6 62 6 821 33 0 1 226 0 0 1 2 2 33 0 2 3101 09 7 8 0 1 5 6 4 3 28 4 3 8 6 2 5 0 17 2 3 0 1 0 4 02 3 19 2 0 5 4 1 3 0 0 07 6 3 2 4 1 8 05 3 2 4 1 04 0 3 1 13 0 3 2
605084319202
For the first test case, we have 3 possible distinct operations:
For the second test case, since no array contains a zero, the value of all operations will be $$$0$$$.
| Name |
|---|


