A + B Problem

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

A binary string is a string consisting only of digits "00" and "11". Given a binary string ss of length (n+m)(n + m), please divide it into two subsequences A=a_1a_2a_nA = a\_1 a\_2 \ldots a\_n of length nn and B=b_1b_2b_mB = b\_1 b\_2 \ldots b\_m of length mm such that each digit in ss belongs to exactly one subsequence.

Let ff be the function that transforms a sequence of "00" and "11" into a binary integer. For example, f(1,0,1,0)=1010_2f(\\{1, 0, 1, 0\\}) = 1010\_2 and f(0,0,1,0)=10_2f(\\{0, 0, 1, 0\\}) = 10\_2. Your task is to find such AA and BB that maximize (f(A)+f(B))(f(A) + f(B)).

Recall that a subsequence of a string is a sequence that can be derived by deleting some characters (possibly none) from the string without changing the order of the remaining characters.

입력

There are multiple test cases. The first line of the input contains an integer TT indicating the number of test cases. For each test case:

The first line contains two integers nn and mm (1n,m1051 \le n, m \le 10^5) indicating the lengths of the desired subsequences.

The second line contains a binary string ss (s=n+m|s| = n + m, s\_i \in \\{\text{"0"}, \text{"1"}\\}).

It is guaranteed that the sum of (n+m)(n + m) of all test cases will not exceed 21062 \cdot 10^6.

출력

For each test case, output one line containing a binary integer indicating the largest possible result of (f(A)+f(B))(f(A) + f(B)). Note that (f(A)+f(B))(f(A) + f(B)) should be printed as a binary integer with no leading zeroes, while AA and BB are sequences, and leading zeros are allowed in the sequences.

힌트

We now use underline to indicate subsequence AA in the binary string.

For the first sample test case, a valid solution is to divide the binary string into 1000101\underline{1}000\underline{101} such that f(1,1,0,1)+f(0,0,0)=1101_2+0_2=1101_2f(\\{1, 1, 0, 1\\}) + f(\\{0, 0, 0\\}) = 1101\_2 + 0\_2 = 1101\_2.

For the second sample test case, a valid solution is to divide the binary string into 1111\underline{1}1\underline{1}1 such that f(1,1)+f(1,1)=11_2+11_2=110_2f(\\{1, 1\\}) + f(\\{1, 1\\}) = 11\_2 + 11\_2 = 110\_2.