#K1361. Library Book Category Check

    ID: 23951 Type: Default 1000ms 256MiB

Library Book Category Check

Library Book Category Check

You are given a library that already contains several book categories. Each category is represented by a series of integers in a single line; the integers denote identification numbers for that category and its subcategories. You are then provided with a list of new book category numbers. Your task is to determine whether it is possible to add all new book categories to the library without causing any conflicts. A conflict occurs if any new book’s category number already exists in any of the already existing categories.

If none of the new book category numbers exists in the library, print YES; otherwise, print NO.

Note: All input should be read from standard input, and output should be written to standard output.

inputFormat

The input is given in the following format from stdin:

  1. An integer n — the number of existing categories.
  2. n lines follow. Each line contains a space-separated list of integers representing the book categories currently in the library.
  3. An integer k — the number of new book categories.
  4. k lines follow. Each line contains a single integer representing a new book category number.

outputFormat

Output a single line to stdout containing either YES if all new book categories can be added without conflict, or NO if there is at least one conflict.

## sample
4
10 9 8 7
5 4 3
12 11
20 15 10 5
3
6
2
13
YES