#K55672. Taco Feature Checker

    ID: 30028 Type: Default 1000ms 256MiB

Taco Feature Checker

Taco Feature Checker

You are given several versions of a software called Taco, each with its own set of features. Each version's data is provided on a single line, where the first number is the version identifier, the second number is a dummy integer, and the remaining numbers represent the features available in that version. Following the versions, you are given several requests. Each request consists of a set of features. For each request, output (YES) if there is at least one version that contains all the requested features, otherwise output (NO). The input is organized in blocks. Each block starts with an integer (N) representing the number of versions. If (N = 0), the input ends. This is followed by (N) lines of version data, then an integer (M) which is the number of requests, and finally (M) lines where each line contains the requested features. All input should be read from the standard input and all output should be written to the standard output.

inputFormat

The input is provided via standard input (stdin). It consists of one or more blocks. Each block begins with an integer (N) ((N > 0)) representing the number of versions. This is followed by (N) lines where each line contains a version's data in the format: <version_id> <dummy_number> ... . After that, there is an integer (M) indicating the number of requests, followed by (M) lines with each line containing a set of space-separated integers that represent the required features. The input terminates when a block starts with (N = 0).

outputFormat

For each request, output a single line containing (YES) if there exists at least one version which possesses all of the requested features, or (NO) if there is none. The outputs should appear in the same order as the requests received.## sample

1
1 3 2 3 4
1
2 3
0
YES