Harish's strings


Submit solution

Points: 15 (partial)
Time limit: 1.0s
Memory limit: 12M

Authors:
Problem type
Allowed languages
C++, Python

Problem

Harish has two binary strings A and B, each of length N.

Harish can rearrange both the strings in any way. Find the maximum bitwise XOR he can achieve if he rearranges the strings optimally.

Input Format

The first line of input will contain a single integer T, denoting the number of test cases.
Each test case consists of two lines:
The first line of each test case contains binary string A.
The second line of each test case contains binary string B.

Output Format

For each test case, output the maximum bitwise XOR of the strings in binary representation.

Constraints

1 <= T <= 1000
1 <= N <= 5x10^5

Strings A and B consist only of 0 and 1.

Sample Input:

2
0011
1011
1
0

Sample Output

1110
1

Explanation:

Test case 1: Rearranging string A as 0011 and string B as 1101, the XOR of the strings is 0011⊕1101 = 1110. It can be shown that this is the maximum XOR that can be achieved by rearranging the strings.

Test case 2: Rearranging string A as 1 and string B as 0, the XOR of the strings is 1⊕0 = 1. It can be shown that this is the maximum XOR that can be achieved by rearranging the strings.


Comments

There are no comments at the moment.