Under construction

Still being built. Things may change

Why did you book it without asking

Time limit1sMemory limit1024 MB

Summary
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 TT fixed periods. Each period is written as a distinct integer from 11 to TT.

Every member told Geonwoo which periods they can attend. Geonwoo reserved period XX without asking anyone. Can all members attend?

Input

The first line contains TT, the number of periods the classroom can be reserved for, and XX, the period Geonwoo reserved, separated by a space. (1≤T≤1 000;(1 \leq T \leq 1\,000; 1≤X≤T)1 \leq X \leq T)

The second line contains NN, the number of team members. (1≤N≤10)(1 \leq N \leq 10)

From the third line on, each member's available periods are given in two lines.

  • The first line contains KiK_i, the number of periods member ii can attend. (1≤Ki≤T)(1 \leq K_i \leq T)
  • The second line contains KiK_i integers Ai,1,Ai,2,…,Ai,KiA_{i,1}, A_{i,2}, \ldots, A_{i,K_i}, the periods member ii can attend, separated by spaces, in ascending order. (1≤Ai,1<Ai,2<⋯<Ai,Ki≤T)(1 \leq A_{i,1} < A_{i,2} < \cdots < A_{i,K_i} \leq T)

All numbers in the input are positive integers.

Output

If all members can attend period XX, print YES. Otherwise, print NO.

Hint

Print YES or NO in all uppercase letters.

Examples2

  1. Example 1

    Input
    12 5
    7
    5
    2 3 5 7 11
    4
    5 7 10 12
    3
    4 5 7
    6
    1 3 5 7 11 12
    12
    1 2 3 4 5 6 7 8 9 10 11 12
    2
    5 7
    9
    1 3 5 6 7 8 9 10 11
    
    Expected output
    YES
    
  2. Example 2

    Input
    7 3
    4
    1
    4
    6
    1 2 4 5 6 7
    3
    1 3 4
    2
    4 7
    
    Expected output
    NO