C. Finding Shapes in the Clouds
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

After eating and settling down on a soft blanket by the lake, Sunny and Aubrey began gazing at the sky. The friends noticed an unusual long band of $$$n$$$ clouds, where each cloud is either fluffy and white (represented as "0") or thin and dark (represented as "1"). Let $$$s$$$ be the current string of cloud types.

While watching the sky, Aubrey noticed an unusual phenomenon: when gusts of wind blow through the cloud band, a "cloud swirl" occurs.

In one cloud swirl, the friends can choose two clouds at positions $$$i$$$ and $$$j$$$ ($$$1 \le i \lt j \le |s|$$$) that have the same type ($$$s_i = s_j$$$). As a result of this wind:

  1. Both selected clouds $$$s_i$$$ and $$$s_j$$$ dissipate and completely disappear from the band.
  2. All clouds located strictly between them (at positions from $$$i+1$$$ to $$$j-1$$$) invert their type due to turbulence: a white cloud ("0") becomes dark ("1"), and a dark cloud ("1") becomes white ("0").
The remaining clouds keep their order and are renumbered starting from one.

Can the friends make the cloud band empty by applying this operation?

Input

Each test consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the initial length of the cloud band.

The second line contains a binary string $$$s$$$ of length $$$n$$$ consisting only of characters '0' and '1'.

The sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

Output

For each test case, print YES if the sky can be completely cleared of clouds, and NO otherwise.

You can output each letter in any case (for example, YES, Yes, yes will be recognized as a positive answer).

Example
Input
7
4
0000
4
0101
6
011010
2
01
3
000
4
1000
6
010001
Output
YES
NO
YES
NO
NO
YES
YES
Note

In the third test case, remove the clouds at positions $$$1$$$ and $$$4$$$ in 011010. After the inversion the band reads 0010. Removing positions $$$2$$$ and $$$4$$$ now leaves 00, whose two clouds can disappear together.

In the fourth test case the two clouds have different types, so there is no legal first move.