atcoder#AGC052A. [AGC052A] Long Common Subsequence

[AGC052A] Long Common Subsequence

Score : 400400 points

Problem Statement

You are given 33 binary strings S1,S2,S3S_1, S_2, S_3, each containing exactly NN 0's and NN 1's.

Find a binary string of length 2N+12N+1, which is a subsequence of all of the strings S1+S1,S2+S2,S3+S3S_1 + S_1, S_2 + S_2, S_3 + S_3 (s+ts+t denotes the concatenation of strings ss and tt in order). It's guaranteed that under the constraints above such a string always exists.

Here a string BB is a subsequence of a string AA if BB can be obtained by removing zero or more characters from AA and concatenating the remaining characters without changing the order.

You will be given TT test cases. Solve each of them.

Constraints

  • 1T1051 \le T \le 10^5
  • 1N1051\le N \le 10^5
  • SiS_i is a binary string of length 2N2N consisting of NN 0's and NN 1's.
  • The sum of NN over all test cases doesn't exceed 10510^5.

Input

Input is given from Standard Input in the following format. The first line of input is as follows:

TT

Then, TT test cases follow, each of which is in the following format:

NN

S1S_1

S2S_2

S3S_3

Output

For each test case, print any binary string of length 2N+12N+1, which is a subsequence of all of S1+S1,S2+S2,S3+S3S_1 + S_1, S_2 + S_2, S_3 + S_3. If many such strings exist, you can print any.

2
1
01
01
10
2
0101
0011
1100
010
11011

In the first case, 010 is a subsequence of 0101, 0101, and 1010.

In the second case, 11011 is a subsequence of 01010101, 00110011, and 11001100.