Codeforces Round 986 (Div. 2)
A
Alice's Adventures in "Chess"
Codeforces
900
原题
←B →
翻译中…

Alice is trying to meet up with the Red Queen in the countryside! Right now, Alice is at position $(0, 0)$, and the Red Queen is at position $(a, b)$. Alice can only move in the four cardinal directions (north, east, south, west).

翻译中…

More formally, if Alice is at the point $(x, y)$, she will do one of the following:

翻译中…
  • go north (represented by N), moving to $(x, y+1)$;
  • go east (represented by E), moving to $(x+1, y)$;
  • go south (represented by S), moving to $(x, y-1)$; or
  • go west (represented by W), moving to $(x-1, y)$.
翻译中…

Alice's movements are predetermined. She has a string $s$ representing a sequence of moves that she performs from left to right. Once she reaches the end of the sequence, she repeats the same pattern of moves forever.

翻译中…

Can you help Alice figure out if she will ever meet the Red Queen?

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

翻译中…

The first line of each test case contains three integers $n$, $a$, $b$ ($1 \le n$, $a$, $b \le 10$) — the length of the string and the initial coordinates of the Red Queen.

翻译中…

The second line contains a string $s$ of length $n$ consisting only of the characters N, E, S, or W.

翻译中…

Output

翻译中…

For each test case, output a single string "YES" or "NO" (without the quotes) denoting whether Alice will eventually meet the Red Queen.

翻译中…

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

翻译中…

Note

翻译中…

In the first test case, Alice follows the path $(0,0) \xrightarrow[\texttt{N}]{} (0,1) \xrightarrow[\texttt{E}]{} (1,1) \xrightarrow[\texttt{N}]{} (1,2) \xrightarrow[\texttt{E}]{} (2,2)$.

翻译中…

In the second test case, Alice can never reach the Red Queen.

翻译中…

样例

Input #1
6
2 2 2
NE
3 2 2
NNE
6 2 1
NNEESW
6 10 10
NNEESW
3 4 2
NEE
4 5 5
NEWS
Output #1
YES
NO
YES
YES
YES
NO
InputCopy OutputCopy
题目信息
题号
2028A
时间限制
1 s
内存限制
256 MB
标签
暴力
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。