You are given \(N\) buttons (numbered from \(1\) to \(N\)) and \(N\) lamps (numbered from \(1\) to \(N\)). Each lamp can either be on or off. Initially, lamp \(i\) is on if \(A_i = 1\), and off if \(A_i = 0\).
Button \(i\) is connected to lamp \(i - 1\) (if \(i > 1\)) and lamp \(i + 1\) (if \(i < N\)). In one move, you can press a button \(i\) only if lamp \(i\) is on. When a button is pressed, the state of the lamps connected to this button is toggled. Formally, the lamps will be on if it was off previously, and the lamps will be off if it was on previously. Note that lamp \(i\) is not connected to button \(i\), thus, the state of lamp \(i\) does not change if button \(i\) is pressed.
After zero or more moves, you want lamp \(i\) to be on if \(B_i = 1\), and off if \(B_i = 0\). Determine if it is possible to achieve this task.
Output
For each test case, output YES in a single line if the final state of all lamps can be reached after zero or more moves, or NO otherwise.
Note
Explanation for the sample input/output #1
For the first test case, by pressing the buttons \(4, 2, 4, 3, 1, 2\) in sequence, the condition of the buttons changes as: \(0101 \rightarrow 0111 \rightarrow 1101 \rightarrow 1111 \rightarrow 1010 \rightarrow 1110 \rightarrow 0100\).
For the second test case, you are unable to press any button, hence it is impossible to reach the final state.
Примеры
| № | Входные данные | Выходные данные |
|
1
|
2 4 0101 0100 3 000 010
|
YES
NO
|
|
2
|
5 7 0101011 1111010 5 11111 00000 4 1101 1101 6 101010 100100 3 000 000
|
NO
NO
YES
YES
YES
|