Codeforces Round 959 sponsored by NEAR (Div. 1 + Div. 2)
B
Fun Game
Codeforces
1100
原题
← AC →
翻译中…

Vova really loves the XOR operation (denoted as $\oplus$). Recently, when he was going to sleep, he came up with a fun game.

翻译中…

At the beginning of the game, Vova chooses two binary sequences $s$ and $t$ of length $n$ and gives them to Vanya. A binary sequence is a sequence consisting only of the numbers $0$ and $1$. Vanya can choose integers $l, r$ such that $1 \leq l \leq r \leq n$, and for all $l \leq i \leq r$ simultaneously replace $s_i$ with $s_i \oplus s_{i - l + 1}$, where $s_i$ is the $i$-th element of the sequence $s$.

翻译中…

In order for the game to be interesting, there must be a possibility to win. Vanya wins if, with an unlimited number of actions, he can obtain the sequence $t$ from the sequence $s$. Determine if the game will be interesting for the sequences $s$ and $t$.

翻译中…

Input

翻译中…

Each test consists of multiple test cases. The first line contains an integer $q$ ($1 \le q \le 10^{4}$) — the number of test cases. Then follows the description of the test cases.

翻译中…

The first line of each test case contains a single integer $n$ ($1 \leq n \leq 2 \cdot 10^5$) — the length of the sequences $s$ and $t$.

翻译中…

The second line of each test case contains a binary sequence $s$ of length $n$.

翻译中…

The third line of each test case contains a binary sequence $t$ of length $n$.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, output "Yes" if the game will be interesting, otherwise output "No".

翻译中…

You can output each letter in any case (for example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as a positive answer).

翻译中…

Note

翻译中…

In the first test case, Vanya will not be able to change the sequence $s$ with the only possible action of choosing $l = r = 1$.

翻译中…

In the second test case, the sequences $s$ and $t$ are already equal.

翻译中…

In the third test case, Vanya can act as follows:

翻译中…
  1. Choose $l = 3$ and $r = 5$, then $s$ will become $\mathtt{101101010}$.
  2. Choose $l = 5$ and $r = 6$, then $s$ will become $\mathtt{101111010}$.
  3. Choose $l = 7$ and $r = 7$, then $s$ will become $\mathtt{101111110}$.
翻译中…

样例

Input #1
6
1
0
1
7
0110100
0110100
9
100101010
101111110
4
0011
1011
4
0100
0001
8
10110111
01100000
Output #1
NO
YES
YES
NO
YES
YES
InputCopy OutputCopy
题目信息
题号
1994B
时间限制
1 s
内存限制
256 MB
标签
位运算
构造
贪心
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。