I. Divination
time limit per test
1 second
memory limit per test
2048 MB
input
standard input
output
standard output

In Yinxu, the archaeological site of the late capital of the Shang Dynasty, there are $$$N$$$ divination papers written in oracle bone script, numbered $$$1, 2, ..., N$$$. Some papers may cite other papers, but no paper can cite itself. Additionally, there are no circular citations, meaning it's not possible to see the following situation: $$$A_1$$$ cites $$$A_2$$$, $$$A_2$$$ cites $$$A_3$$$, ..., $$$A_{K-1}$$$ cites $$$A_K$$$, $$$A_K$$$ cites $$$A_1$$$ (where $$$2 \leqslant K \leqslant N$$$).

As per myth, a complete set of divination papers can predict the wars and peace of the next century, and it should have a complete citation chain, i.e., $$$A_1$$$ cites $$$A_2$$$, $$$A_2$$$ cites $$$A_3$$$, ..., $$$A_{N-1}$$$ cites $$$A_N$$$, without any papers missing. Please determine whether these $$$N$$$ divination papers constitute a complete set.

Input

The first line contains an integer $$$N$$$, represents the number of papers. Then $$$N$$$ lines follow, the $$$i^{\texttt{th}}$$$ of them represents the citations of the $$$i^{\texttt{th}}$$$ paper: the first integer $$$c_i$$$ represents the number of its citations, followed by $$$c_i$$$ integers $$$p_{i,1}, p_{i,2}, ..., p_{i,{c_i}}$$$ that represent the papers that it cites.

Output

A single integer, 1 if they constitute a complete set of divination papers, or 0 otherwise.

Limits

  •  $$$2 \leqslant N \leqslant 100\ 000$$$;
  •  $$$0 \leqslant c_i\leqslant N-1$$$ for all $$$i \leqslant N$$$;
  •  $$$0 \leqslant c_1 + c_2 + ... + c_N \leqslant 500\ 000$$$;
  •  $$$1 \leqslant p_{i,j} \leqslant N$$$ for all $$$i \leqslant N$$$ and $$$j \leqslant {c_i}$$$.
  •  $$$p_{i,j} \neq i$$$ for all $$$i \leqslant N$$$ and $$$j \leqslant {c_i}$$$.
Examples
Input
4
0
2 1 4
2 2 4
1 1
Output
1
Input
4
0
1 1
2 2 4
1 1
Output
0
Note

Sample Explanation 1

In the first sample, paper $$$3$$$ cites paper $$$2$$$, paper $$$2$$$ cites paper $$$4$$$, paper $$$4$$$ cites paper $$$1$$$. Thus, we find a complete citation chain, which makes them a complete set of divination papers.