#C3930. Taco Ingredient Combination

    ID: 47412 Type: Default 1000ms 256MiB

Taco Ingredient Combination

Taco Ingredient Combination

In this problem, you are given (n) ingredients and (m) pairs representing incompatible ingredients. Two ingredients (u) and (v) are incompatible if they cannot be used together. You will be given (q) queries, each specifying a subset of ingredients. For each query, determine whether the selected ingredients can be combined without including any pair of incompatible ingredients. If the subset contains no incompatible pairs, output (YES); otherwise, output (NO).

inputFormat

The input is given through standard input with the following format:

  1. The first line contains two integers (n) and (m), representing the number of ingredients and the number of incompatible pairs, respectively.
  2. The next (m) lines each contain two integers (u) and (v) that describe an incompatible pair of ingredients.
  3. The following line contains an integer (q), denoting the number of queries.
  4. Each of the next (q) lines begins with an integer (k) (the number of ingredients in the query) followed by (k) space-separated integers representing the ingredients in the subset.

outputFormat

For each query, print a single line containing (YES) if the queried subset has no incompatible pairs, and (NO) otherwise.## sample

5 3
1 2
2 3
4 5
3
3 1 3 4
2 2 5
4 1 2 3 4
YES

YES NO

</p>