시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB1411888.889%

문제

You are given a string $S$ of length $N$. There are $Q$ queries (numbered from $1$ to $Q$) that you need to answer. For query $i$, determine if a string $T_i$ of length $N$, can be obtained by performing the following algorithm from the initial string $S$.

  1. First, split the string $S$ into one or more substrings.
  2. Reverse the order of the substrings.
  3. Concatenate the substrings into a single string.

For instance, you can obtain string SEVERER from string REVERSE by splitting it into R, E, VER, and SE. After reversing the order of the substrings, your substrings will be SE, VER, E, and R. If you concatenate the substrings, then you can obtain string SEVERER.

입력

The first line consists of an integer $N$ ($1 ≤ N ≤ 10\, 000$).

The second line consists of a string $S$ of length $N$.

The third line consists of an integer $Q$ ($1 ≤ Q ≤ 100$)

Each of the next $Q$ lines consists of a string $T_i$ of length $N$.

All strings consist of only upper-case letters.

출력

For each query, output a single line containing a string. If string $T_i$ can be obtained from the algorithm above, output YES. Otherwise, output NO.

예제 입력 1

7
REVERSE
5
SEVERER
EVERSER
REVERSE
EVEREST
RESERVE

예제 출력 1

YES
YES
YES
NO
NO

For query $2$, you can split the string into R and EVERSE.

For query $3$, note that you can split the string into one substring REVERSE.

예제 입력 2

3
INC
6
INC
ICN
NIC
NCI
CIN
CNI

예제 출력 2

YES
NO
NO
YES
YES
YES

예제 입력 3

1
A
2
A
B

예제 출력 3

YES
NO