#P1951A. Dual Trigger

    ID: 10514 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>constructive algorithmsgreedymath

Dual Trigger

Description

There are nn lamps numbered 11 to nn lined up in a row, initially turned off. You can perform the following operation any number of times (possibly zero):

  • Choose two non-adjacent{}^\dagger lamps that are currently turned off, then turn them on.

Determine whether you can reach configuration ss, where si=1s_i = 1 means the ii-th lamp is turned on, and si=0s_i = 0 otherwise.

{}^\dagger Only lamp ii and i+1i + 1 are adjacent for all 1i<n1 \le i < n. Note that lamp nn and 11 are not adjacent when n2n \ne 2.

Each test contains multiple test cases. The first line contains an integer tt (1t10001 \le t \le 1000) — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer nn (1n501 \le n \le 50) — the number of lamps.

The second line of each test case contains a binary string ss of size nn — the final desired configuration.

For each test case, print on one line "YES" if we can reach the configuration ss via applying the given operation any number of times. Otherwise, print "NO".

Input

Each test contains multiple test cases. The first line contains an integer tt (1t10001 \le t \le 1000) — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer nn (1n501 \le n \le 50) — the number of lamps.

The second line of each test case contains a binary string ss of size nn — the final desired configuration.

Output

For each test case, print on one line "YES" if we can reach the configuration ss via applying the given operation any number of times. Otherwise, print "NO".

Sample Input 1

5
10
1101010110
10
1001001110
6
000000
1
1
12
111111111111

Sample Output 1

YES
NO
YES
NO
YES

Note

In the first test case, the sequence of operation could have been as follows (note that initially ss is all zero): 0000000000100000001011000001101101010110\mathtt{0000000000} \to \mathtt{\color{red}{1}0000000\color{red}{1}0} \to \mathtt{1\color{red}{1}00000\color{red}{1}10} \to \mathtt{110\color{red}{1}0\color{red}{1}0110}.

In the third test case, we don't have to do any operation.

In the fourth test case, we cannot do any operation, but we need the first lamp to be on. Therefore, it is impossible to achieve the desired state.