1IXMMMl310dKFF#</["

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Statement

You are given a sequence [a1,,an] [a_1,\ldots,a_n] where each element ai a_i is either 0 0 or 1 1 . You can apply several (possibly zero) operations to the sequence. In each operation, you select two integers 1lra 1\le l\le r\le |a| (where a |a| is the current length of a a ) and replace [al,,ar] [a_l,\ldots,a_r] with a single element x x , where x x is the majority of [al,,ar] [a_l,\ldots,a_r] .

Here, the majority of a sequence consisting of 0 0 and 1 1 is defined as follows: suppose there are c0 c_0 zeros and c1 c_1 ones in the sequence, respectively.

  • If c0c1 c_0\ge c_1 , the majority is 0 0 .
  • If c0<c1 c_0<c_1 , the majority is 1 1 .

For example, suppose a=[1,0,0,0,1,1] a=[1,0,0,0,1,1] . If we select l=1,r=2 l=1,r=2 , the resulting sequence will be [0,0,0,1,1] [0,0,0,1,1] . If we select l=4,r=6 l=4,r=6 , the resulting sequence will be [1,0,0,1] [1,0,0,1] .

Determine if you can make a=[1] a=[1] with a finite number of operations.

Format

Input

Each test contains multiple test cases. The first line contains the number of test cases t t ( 1t4104 1 \le t \le 4\cdot 10^4 ). Description of the test cases follows.

The first line of each testcase contains one integer n n ( 1n2105 1\le n\le 2\cdot 10^5 ).

The second line of each testcase contains a string consisting of 0 0 and 1 1 , describing the sequence a a .

It's guaranteed that the sum of n n over all testcases does not exceed 2105 2\cdot 10^5 .

Output

For each testcase, if it's possible to make a=[1] a=[1] , print Yes. Otherwise, print No.

Sample

5
1
0
1
1
2
01
9
100000001
9
000011000
No
Yes
No
Yes
No

ShanghaiTech ACM 炸鱼杯

未参加
状态
已结束
规则
OI
题目
46
开始于
2024-12-10 23:00
结束于
2024-12-15 13:00
持续时间
110 小时
主持人
参赛人数
112