


The first line contains a single integer ‘T’ representing the number of test cases.
The second line contains two space-separated integers ‘N’ and ‘M’ which are the length of strings ‘A’ and ‘B’ respectively.
The third line of each test case will contain two space-separated binary strings ‘A’ and ‘B’ as described above.
For each test case, print the sum of the given binary strings in a binary form.
Output for every test case will be printed in a separate line.
You don’t need to print anything; It has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N, M <= 5000
‘A’ and ‘B’ consist only of '0' or '1' characters.
Each string does not contain leading zeros except for the zero itself.
Time limit: 1 sec
The basic idea of this approach is to start doing bit by bit addition while keeping track of the carry bit from the least significant bits, i.e. from the end of the strings. Let say ‘a’ is the current bit of ‘A’ and ‘b’ is the current bit of ‘B’ and ‘c’ is the carry bit. Now, we want to add those bits and get the resulting “sum” and new “carry” bits. Consider the boolean table:
| ‘a’ | ‘b’ | ‘c’ | “sum” | “carry” |
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 |
After observing closely, we can find the “SUM” is (‘a’ + ‘b’ + ‘c’) % 2 and “CARRY” is (‘a’ + ‘b’ + ‘c’) / 2.
Steps are as follows: