#D3934. Ghost Legs

    ID: 3263 Type: Default 1000ms 536MiB

Ghost Legs

Ghost Legs

Problem

There are N N Amidakuji with 3 vertical lines. No matter which line you start from, the Amidakuji that ends at the starting line is considered a good Amidakuji. You can select one or more Amidakuji and connect them vertically in any order. Output "yes" if you can make a good Amidakuji, otherwise output "no".

There are wi w_i horizontal lines in the i i th Amidakuji. ai,j a_ {i, j} indicates whether the j j th horizontal bar from the top of Amidakuji i i extends from the central vertical line to the left or right. If ai,j a_ {i, j} is 0, it means that it extends to the left, and if it is 1, it means that it extends to the right.

Constraints

The input satisfies the following conditions.

  • 1 leN le50 1 \ le N \ le 50
  • 0 lewi le100 0 \ le w_i \ le 100
  • ai,j a_ {i, j} is 0 or 1

Input

The input is given in the following format.

N N w1 w_1 a1,1 a_ {1,1} a1,2 a_ {1,2} ... a1,w1 a_ {1, w_1} w2 w_2 a2,1 a_ {2,1} a2,2 a_ {2,2} ... a2,w2 a_ {2, w_2} ... wN w_N aN,1 a_ {N, 1} aN,2 a_ {N, 2} ... aN,wN a_ {N, w_N}

All inputs are given as integers. N N is given on the first line. Wi W_i and wi w_i ai,j a_ {i, j} are given on the following N N line, separated by blanks.

Output

If you can make a good Amidakuji, it outputs "yes", otherwise it outputs "no".

Examples

Input

3 2 0 0 1 1 5 1 0 0 1 0

Output

yes

Input

2 1 1 1 0

Output

no

inputFormat

outputFormat

Output "yes" if you can make a good Amidakuji, otherwise output "no".

There are wi w_i horizontal lines in the i i th Amidakuji. ai,j a_ {i, j} indicates whether the j j th horizontal bar from the top of Amidakuji i i extends from the central vertical line to the left or right. If ai,j a_ {i, j} is 0, it means that it extends to the left, and if it is 1, it means that it extends to the right.

Constraints

The input satisfies the following conditions.

  • 1 leN le50 1 \ le N \ le 50
  • 0 lewi le100 0 \ le w_i \ le 100
  • ai,j a_ {i, j} is 0 or 1

Input

The input is given in the following format.

N N w1 w_1 a1,1 a_ {1,1} a1,2 a_ {1,2} ... a1,w1 a_ {1, w_1} w2 w_2 a2,1 a_ {2,1} a2,2 a_ {2,2} ... a2,w2 a_ {2, w_2} ... wN w_N aN,1 a_ {N, 1} aN,2 a_ {N, 2} ... aN,wN a_ {N, w_N}

All inputs are given as integers. N N is given on the first line. Wi W_i and wi w_i ai,j a_ {i, j} are given on the following N N line, separated by blanks.

Output

If you can make a good Amidakuji, it outputs "yes", otherwise it outputs "no".

Examples

Input

3 2 0 0 1 1 5 1 0 0 1 0

Output

yes

Input

2 1 1 1 0

Output

no

样例

3
2 0 0
1 1
5 1 0 0 1 0
yes