#C4312. Taco Party Satisfaction

    ID: 47837 Type: Default 1000ms 256MiB

Taco Party Satisfaction

Taco Party Satisfaction

Welcome to the Taco Party! You are given a list of available items and a set of people, each with their own list of preferred items. Your task is to decide if every person can have at least one of the items they like from the available set.

More formally, let \(A\) be the set of available items and for each person \(i\) let \(P_i\) be the set of items they prefer. The party is considered a success if and only if \(A \cap P_i \neq \emptyset\) for all persons \(i\). If this condition holds, output yes; otherwise, output no.

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

  • The first line contains two integers \(i\) and \(p\), representing the number of available items and the number of people, respectively.
  • The second line contains \(i\) strings representing the available items.
  • The following \(p\) lines each describe a person's preferences. Each of these lines begins with an integer \(k\) (the number of items the person prefers), followed by \(k\) strings indicating the preferred items.

outputFormat

Output a single string to standard output (stdout): either yes if every person can be satisfied with at least one available item in their preferences, or no otherwise.

## sample
5 3
burger hotdog fries salad soda
2 burger soda
3 fries hotdog salad
1 hotdog
yes