CF2092B Lady Bug
Description
As soon as Dasha Purova crossed the border of France, the villain Markaron kidnapped her and placed her in a prison under his large castle. Fortunately, the wonderful Lady Bug, upon hearing the news about Dasha, immediately ran to save her in Markaron's castle. However, to get there, she needs to crack a complex password.
The password consists of two bit strings $ a $ and $ b $ , each of which has a length of $ n $ . In one operation, Lady Bug can choose any index $ 2 \le i \le n $ and perform one of the following actions:
1. swap( $ a_i $ , $ b_{i-1} $ ) (swap the values of $ a_i $ and $ b_{i-1} $ ), or
2. swap( $ b_i $ , $ a_{i-1} $ ) (swap the values of $ b_i $ and $ a_{i-1} $ ).
Lady Bug can perform any number of operations. The password is considered cracked if she can ensure that the first string consists only of zeros. Help her understand whether or not she will be able to save the unfortunate Dasha.
Input Format
Each test consists of several test cases. The first line of the input data contains one integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains one integer $ n $ ( $ 2 \leq n \leq 2 \cdot 10^5 $ ) — the length of the bit strings of the password.
The next two lines contain the bit strings of length $ n $ , $ a $ and $ b $ , which represent the password. Each of the strings contains only the characters 0 and '1'.
It is guaranteed that the sum of $ n $ across all test cases does not exceed $ 2 \cdot 10^5 $ .
Output Format
For each test case, output "YES" if Lady Bug can crack the password after any number of operations; otherwise, output "NO".
You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.
Explanation/Hint
In the first test case, the string $ a $ immediately consists only of zeros.
In the second test case, a possible sequence of operations is:
1. swap $ (a_2, \ b_{1}) $
$ \mathtt{0{\color{red}{1}}0001} $
$ \mathtt{{\color{red}{0}}10111} $
2. swap $ (b_5, \ a_{4}) $
$ \mathtt{000{\color{red}{0}}01} $
$ \mathtt{1101{\color{red}{1}}1} $
3. swap $ (a_4, \ b_{3}) $
$ \mathtt{000{\color{red}{1}}01} $
$ \mathtt{11{\color{red}{0}}101} $
4. swap $ (a_5, \ b_{4}) $
$ \mathtt{00000{\color{red}{1}}} $
$ \mathtt{1111{\color{red}{0}}1} $