CF2157B.Expansion Plan 2

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

Expansion Plan 2

ak+q - over the crimson skies

You are analyzing an infinite grid with coordinates (X,Y)(X, Y) (specifically, the cell immediately above (0,0)(0, 0) is (0,1)(0, 1), and the cell immediately on the right of (0,0)(0, 0) is (1,0)(1, 0)). Initially, only the cell at (0,0)(0, 0) is black.

You are given a string a1a2ana_1a_2 \ldots a_n of length nn consisting of characters "4" and "8", which describes nn expansion operations. For each ii from 11 to nn, the following happens for all cells simultaneously:

  • if si="4"s_i = \texttt{"4"}: for each cell, if it is orthogonally adjacent to a black cell (i.e., it shares a side), it becomes black; otherwise, its state remains the same;
  • if si="8"s_i = \texttt{"8"}: for each cell, if it is orthogonally or diagonally adjacent to a black cell (i.e, it shares a side or a corner), it becomes black; otherwise, its state remains the same.

Is the cell (x,y)(x, y) black at the end of the process?

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1041 \le t \le 10^4). The description of the test cases follows.

The first line of each test case contains three integers nn, xx, yy (1n2105,109x,y1091 \le n \le 2 \cdot 10^5, -10^9 \le x, y \le 10^9) — the number of expansion operations, and the xx and yy coordinates of the cell you are interested in, respectively.

The second line of each test case contains a string ss of length nn consisting of characters "4" and "8" — the types of expansion operations.

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case, output YES if the cell (x,y)(x, y) is black after the expansion operations described by the string ss, and NO otherwise.

The judge is case-insensitive (for example, YES, Yes, yes, yEs will all be recognized as positive answers).

Note

The first three test cases are illustrated below:

In the first test case, after the expansion operations in the string "888", cell (3,3)(3, 3) is black, so the answer is YES.

In the second test case, cell (5,1)(5, 1) is white after the expansion operations in the string "4884".

Samples

6
3 3 3
888
4 5 1
4884
4 3 -3
4884
7 -7 -5
4884884
10 0 0
4884884888
1 1 1
4
YES
NO
YES
NO
YES
NO

在线编程 IDE

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