407647: GYM102862 K Binary Sequence
Description
You are given a sequence of $$$n$$$ bits $$$a_1$$$, $$$\ldots$$$, $$$a_n$$$ (each bit can be either $$$0$$$ or $$$1$$$). Initially all bits are set to $$$0$$$. You are also given $$$m$$$ pairs of indices $$$(i,j)$$$, which are the possible operations you can apply to the sequence. If you apply an operation $$$(i,j)$$$, $$$a_i$$$ changes to $$$1-a_i$$$ and $$$a_j$$$ to $$$1-a_j$$$.
You are also given a target sequence of $$$n$$$ bits $$$b_1$$$, $$$\ldots$$$, $$$b_n$$$. Determine if it is possible to obtain $$$b$$$ from $$$a$$$ by applying the available operations (you can also not change the array at all). Each operation can be applied zero or multiple times, and operations may be appplied in any order.
InputThe first line of input contains a single integer, the value of $$$n$$$ ($$$2 \leq n \leq 10^5$$$). The following line contains $$$n$$$ bits $$$b_1$$$, $$$\ldots$$$, $$$b_n$$$ ($$$0 \leq b_i \leq 1$$$).
The next line contains a single integer, the value of $$$m$$$ ($$$1 \leq m \leq 10^5$$$). The next $$$m$$$ lines each contains two integers $$$l_i$$$ and $$$r_i$$$, the indexes of an operation ($$$1 \leq l_i < r_i \leq n$$$). No two operations are equal.
OutputOutput "Yes", if it is possible, and "No" otherwise.
ExamplesInput5 1 1 0 1 1 3 1 3 3 4 2 5Output
YesInput
2 0 1 1 1 2Output
No