Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Crayons

Limits 1s, 32 MB

Five friends A, B, C, D and E has come to a shop to buy crayons for their art project. They need crayons of Na, Nb, Nc, Nd and Ne distinct colors respectively. The shop has a strange rule. There are M crayons in the shop arranged in a row numbered from 1 to M. If you want to buy crayons, you have to choose two numbers L and R where 1 ≤ L ≤ R ≤M and then you have to buy all the crayons numbered from L to R.

Each of five friends wants to choose L and R in such a way that he gets equal to or more than the number of colors of crayons he needs. But they are not so good in calculation. So they called their programmer friend, you!

They will give you Q queries. In each query one of five friends will ask you if he chooses L and R, will he get equal to or more than the number of colors of crayons he needs?

Write a program that will answer each of those queries.

Input

First line of the input contains five integers Na, Nb, Nc, Nd and Ne. Each of these integers will be in the range [1,105].

Second line of the input contains two integers M (1 ≤ M ≤ 105) and Q (1 ≤ Q ≤ 105) where M is the number of crayons and Q is the number of queries.

Third line of the input contains M integers C1, C2, C3, …, CM where Ci (1 ≤ Ci ≤ 109) represents the color of the i-th crayon.

Each of the next Q lines will contain a query of the form: X L R.

Here X is a character from the set {A, B, C, D, E} indicating which friend is doing the query.

L and R (1≤ L ≤ R ≤ M) are integers.

Output

For each query of the form X L R print a single line of output.

If X can get his required number of colors of crayons or more than that by choosing L and R then print “Yes”. Otherwise, print “No”.

Sample

InputOutput
1 2 3 4 5
10 5
1 4 2 1 1 5 2 7 8 7
A 3 3
B 4 5
C 2 7
D 7 10
E 5 10
Yes
No
Yes
No
Yes


Discussion
Statistics
Submit

Login to submit