kriti-and-game
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

Kriti and Me were getting bored, so we finally came up with an idea of a cool game.
The game is described as follows.
1. Initially, we have a stack of n disks.
2. A player in his/her turn can remove a certain number of disks from the stack.
3. The player who can't remove the disks in his/her turn loses.
4. In the beginning, we will be provided with 2 sets, S and K, (of size Ssize and Ksize), 1 for me and other for Kriti.
The number of disks any player can remove from the stack in his/her turn must be an element of his/her set.

Provided that the 2 players play alternatively and optimally, help me guess if I can win the game or not.

Input Format:

Input begins with 2 positive integers Ksize and Ssize denoting the size of Kriti's and My set respectively.
The next line contains Ksize positive integers, denoting the elements of Kriti's set.
Similarly, the following line contains Ssize positive integers denoting, the elements of my set.

Next line contains a positive integer Q, the number of queries.
Each of the next Q lines contain an positive integer n and a character c denoting who will play first.
'S' means I will start the game. 'K' means Kriti will play first.

Output Format:
For each n, print "YES" if I can win the game else print "NO" in a new line.(All alphabets in capital, quotes only for clarification).

Scoring Criteria:

20 Points: 1 ≤ K, S ≤ 3,  1 ≤ S[i], K[i] ≤ 5     and 1 ≤ Q ≤5 and n ≤ 10
50 Points: 1 ≤ K, S ≤ 50,  1 ≤ S[i], K[i] ≤ 100   and 1 ≤ Q ≤100 and n ≤ 1000 
130 Points: 1 ≤ K, S ≤ 100, 1 ≤ S[i], K[i] ≤ 1000  and 1 ≤ Q ≤ 10000 and n ≤ 100000

SAMPLE INPUT
3 3
2 4 5
1 5 7
4
2 S
3 S
3 K
5 K

SAMPLE OUTPUT
YES
NO
YES
NO

Explanation

In first test case, I can remove 1 disk, and Kriti is left with no choice.
In second test case, I have no choice except to remove 1 disk. Kriti will remove 2 disk afterwards and win.