CF1902A.Binary Imbalance

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Binary Imbalance

You are given a string ss, consisting only of characters '0' and/or '1'.

In one operation, you choose a position ii from 11 to s1|s| - 1, where s|s| is the current length of string ss. Then you insert a character between the ii-th and the (i+1)(i+1)-st characters of ss. If si=si+1s_i = s_{i+1}, you insert '1'. If sisi+1s_i \neq s_{i+1}, you insert '0'.

Is it possible to make the number of zeroes in the string strictly greater than the number of ones, using any number of operations (possibly, none)?

Input

The first line contains a single integer tt (1t1001 \le t \le 100) — the number of testcases.

The first line of each testcase contains an integer nn (1n1001 \le n \le 100).

The second line contains a string ss of length exactly nn, consisting only of characters '0' and/or '1'.

Output

For each testcase, print "YES" if it's possible to make the number of zeroes in ss strictly greater than the number of ones, using any number of operations (possibly, none). Otherwise, print "NO".

Note

In the first testcase, the number of zeroes is already greater than the number of ones.

In the second testcase, it's impossible to insert any zeroes in the string.

In the third testcase, you can choose i=1i = 1 to insert a zero between the 11-st and the 22-nd characters. Since s1s2s_1 \neq s_2, you insert a '0'. The resulting string is "100". It has two zeroes and only a single one, so the answer is "YES".

Samples

3
2
00
2
11
2
10
YES
NO
YES

在线编程 IDE

建议全屏模式获得最佳体验