Water supply#40

Water supply

1 second
64 megabytes
Easy

The city consists of districts (1 \leq n \leq 100). Each district has a well for sourcing water. Every pair of wells is connected by a pipe, and water can flow through each pipe in only one direction. Due to an energy crisis, only one well can operate at any given time. Since the system was not designed for this mode of operation, some districts may sometimes be left without water.

Determine whether it is possible to ensure continuous water supply to the entire city by reversing the direction of water flow in all pipes connected to a single well.

Input

The first line contains the number of districts . The following lines describe each well: the number of wells from which it receives water, followed by their indices. Wells are numbered from to .

Output

Output a single integer: 1 if it is possible to provide continuous water supply for the city, or 0 otherwise.

Examples

Example 1

Loading
Loading