Rotated Necklaces


Submit solution

Points: 10
Time limit: 2.0s
Memory limit: 256M

Author:
Problem types

A candidate necklace matches a sample if it is a cyclic rotation of the sample. Check each candidate independently.

Input

The first line contains n and k (1 ≤ n ≤ 100000, 1 ≤ k ≤ 10). The second line is the sample lowercase string of length n. The next k lines are candidate strings.

Output

For each candidate print YES if it is a cyclic rotation of the sample; otherwise print NO.

Examples

Input #1
5 4
abcde
abcde
bcdea
cbaed
cdeab
Output #1
YES
YES
NO
YES
Input #2
1 3
a
a
b
aa
Output #2
YES
NO
NO


Comments

There are no comments at the moment.