Why did you book it without asking
Time limit1sMemory limit1024 MB
Given each member's list of attendable periods, the task is to check whether the reserved period X is in every list.
- Level
Easy1 of 10
- Topics
- Implementation, Array
- Solved
- No attempts yet
Problem
Geonwoo became the team leader for a group project at Daejeon Science High School. To run the project, the team needs a classroom reserved at a period that every member can attend.
The classroom can only be used in fixed periods. Each period is written as a distinct integer from to .
Every member told Geonwoo which periods they can attend. Geonwoo reserved period without asking anyone. Can all members attend?
Input
The first line contains , the number of periods the classroom can be reserved for, and , the period Geonwoo reserved, separated by a space.
The second line contains , the number of team members.
From the third line on, each member's available periods are given in two lines.
- The first line contains , the number of periods member can attend.
- The second line contains integers , the periods member can attend, separated by spaces, in ascending order.
All numbers in the input are positive integers.
Output
If all members can attend period , print YES. Otherwise, print NO.
Hint
Print YES or NO in all uppercase letters.