题目描述
Problem Description
You are given two integer sequences of length $N$: $ (A_1, A_2, ..., A_N) $ and $ (B_1, B_2, ..., B_N) $. You can perform the following operation repeatedly on sequence $A$:
- Choose an integer $i$ ($1 \leq i \leq N-1$). Then, replace either $A_i$ with $A_i$ $xor$ $A_{i+1}$ or $A_{i+1}$ with $A_i$ $xor$ $A_{i+1}$.
Here, $xor$ denotes the bitwise exclusive OR operation.
Determine whether it is possible to make sequence $A$ match sequence $B$ by repeating this operation.
Input Format
The input is given from the standard input in the following format:
$N$ $A_1$ $A_2$ ... $A_N$ $B_1$ $B_2$ ... $B_N$
Output Format
Output Yes if it is possible to make sequence $A$ match sequence $B$ by repeating the operations described in the problem statement. Otherwise, output No.
Sample Input and Output
Sample Input #1
4
4 6 1 2
4 0 3 2
Sample Output #1
Yes
Sample Input #2
5
1 1 1 1 1
2 2 2 2 2
Sample Output #2
No
Sample Input #3
10
9078757738433288 290842434722050 159090006056 289488767243292968 141906289967362 3848861155586 19265097448903424 5761445266577952 616899717105952 343731622434
546704308666859716 487893585065153542 489415167130509384 152982254363317262 324189516636095686 286066742397022348 90758284568626244 239298268501286990 196514071259067468 466853324654813188
Sample Output #3
No
Sample Input #4
12
377856130335197936 431521378213127644 96779183645318069 27884533191077098 175463727782485301 417798313887768470 882780118961099438 695638305642195413 844098458810131862 714758857685818365 982440320392901313 58851425009165345
200247916520409945 1079265167001944511 228890967431065270 594413217207808713 799020374004987514 1064838643421037658 816982417931746301 59262707979926837 802875123164857614 244683246935893681 50108983568402635 248665965512365971
Sample Output #4
Yes
Notes/Hints
Constraints
- $1 \leq N \leq 100000$
- $A_i, B_i$ are integers
- $0 \leq A_i \leq 2^{60} - 1$
- $0 \leq B_i \leq 2^{60} - 1$
Sample Explanation 1
Initially, $A$ is $ (4, 6, 1, 2) $.
- Choose $i=2$ and replace $A_2$ with $A_2$ $xor$ $A_3$, then $A$ becomes $ (4, 7, 1, 2) $.
- Choose $i=1$ and replace $A_2$ with $A_1$ $xor$ $A_2$, then $A$ becomes $ (4, 3, 1, 2) $.
- Choose $i=3$ and replace $A_3$ with $A_3$ $xor$ $A_4$, then $A$ becomes $ (4, 3, 3, 2) $.
- Choose $i=2$ and replace $A_2$ with $A_2$ $xor$ $A_3$, then $A$ becomes $ (4, 0, 3, 2) $.
Thus, it is possible to match $A$ with $B$.
Sample Explanation 2
No matter what operations are performed, it is impossible to match $A$ with $B$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分