#D3934. Ghost Legs
Ghost Legs
Ghost Legs
Problem
There are 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 horizontal lines in the th Amidakuji. indicates whether the th horizontal bar from the top of Amidakuji extends from the central vertical line to the left or right. If 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.
- is 0 or 1
Input
The input is given in the following format.
... ... ... ...
All inputs are given as integers. is given on the first line. and are given on the following 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 horizontal lines in the th Amidakuji. indicates whether the th horizontal bar from the top of Amidakuji extends from the central vertical line to the left or right. If 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.
- is 0 or 1
Input
The input is given in the following format.
... ... ... ...
All inputs are given as integers. is given on the first line. and are given on the following 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