#P1170E. Sliding Doors

    ID: 2484 Type: RemoteJudge 3000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>*special problembinary search

Sliding Doors

No submission language available for this problem.

Description

Imagine that you are the CEO of a big old-fashioned company. Unlike any modern and progressive company (such as JetBrains), your company has a dress code. That's why you have already allocated a spacious room for your employees where they can change their clothes. Moreover, you've already purchased an mm-compartment wardrobe, so the ii-th employee can keep his/her belongings in the ii-th cell (of course, all compartments have equal widths).

The issue has occurred: the wardrobe has sliding doors! More specifically, the wardrobe has nn doors (numbered from left to right) and the jj-th door has width equal to aja_j wardrobe's cells. The wardrobe has single rails so that no two doors can slide past each other.

Extremely schematic example of a wardrobe: m=9m=9, n=2n=2, a1=2a_1=2, a2=3a_2=3.

The problem is as follows: sometimes to open some cells you must close some other cells (since all doors are placed on the single track). For example, if you have a 44-compartment wardrobe (i.e. m=4m=4) with n=2n=2 one-cell doors (i.e. a1=a2=1a_1=a_2=1) and you need to open the 11-st and the 33-rd cells, you have to close the 22-nd and the 44-th cells.

As CEO, you have a complete schedule for the next qq days. Now you are wondering: is it possible that all employees who will come on the kk-th day can access their cells simultaneously?

The first line contains two integers nn and mm (1n21051 \le n \le 2 \cdot 10^5, 1m41051 \le m \le 4 \cdot 10^5) — the number of doors and compartments respectively.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1aim1 \le a_i \le m, aim\sum{a_i} \le m) — the corresponding widths of the doors.

The third line contains a single integer qq (1q21051 \le q \le 2 \cdot 10^5) — the number of days you have to process.

The next qq lines describe schedule of each day. Each schedule is represented as an integer ckc_k followed by ckc_k integers w1,w2,,wckw_1, w_2, \dots, w_{c_k} (1ck21051 \le c_k \le 2 \cdot 10^5, 1w1<w2<<wckm1 \le w_1 < w_2 < \dots < w_{c_k} \le m) — the number of employees who will come on the kk-th day, and their indices in ascending order.

It's guaranteed that ck\sum{c_k} doesn't exceed 21052 \cdot 10^5.

Print qq answers. Each answer is "YES" or "NO" (case insensitive). Print "YES" if it is possible, that all employees on the corresponding day can access their compartments simultaneously.

Input

The first line contains two integers nn and mm (1n21051 \le n \le 2 \cdot 10^5, 1m41051 \le m \le 4 \cdot 10^5) — the number of doors and compartments respectively.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1aim1 \le a_i \le m, aim\sum{a_i} \le m) — the corresponding widths of the doors.

The third line contains a single integer qq (1q21051 \le q \le 2 \cdot 10^5) — the number of days you have to process.

The next qq lines describe schedule of each day. Each schedule is represented as an integer ckc_k followed by ckc_k integers w1,w2,,wckw_1, w_2, \dots, w_{c_k} (1ck21051 \le c_k \le 2 \cdot 10^5, 1w1<w2<<wckm1 \le w_1 < w_2 < \dots < w_{c_k} \le m) — the number of employees who will come on the kk-th day, and their indices in ascending order.

It's guaranteed that ck\sum{c_k} doesn't exceed 21052 \cdot 10^5.

Output

Print qq answers. Each answer is "YES" or "NO" (case insensitive). Print "YES" if it is possible, that all employees on the corresponding day can access their compartments simultaneously.

Samples

Sample Input 1

3 10
2 3 2
6
1 5
2 1 10
2 2 9
2 5 6
3 1 7 8
4 1 2 3 4

Sample Output 1

YES
YES
NO
NO
YES
NO