/*
Question:
On-duty questions: give everyone their spare time and ask if they can schedule a person on duty at every time.
Analysis:
The problem of binary matching is illustrated by the link between a person and his spare time. Then the hungry algorithm is simple.
*/
# Include
<Iostream>
# Include
<Cstring>
# Include
<Cstdio>
Using namespace
Std;
# Define X 22
Bool
G [X] [X], use [X];
Int
Xm [X], ym [X], k, p;
Bool dfs (int u)
{
For (int v = 0; v <k; v ++)
If (g [u] [v] &! Use [v])
{
Use [v] = true;
If (ym [v] =-1 | dfs (ym [v])
{
Xm [u] = v;
Ym [v] = u;
Return true;
}
}
Return false;
}
Int hungry ()
{
Int ret = 0;
Memset (xm,-1, sizeof (xm ));
Memset (ym,-1, sizeof (ym ));
For (int u = 0; u <p; u ++)
If (xm [u] =-1)
{
Memset (use, false, sizeof (use ));
If (dfs (u ))
Ret ++;
}
Return ret;
}
Int main ()
{
Freopen ("sum. in", "r", stdin );
Freopen ("sum. out", "w", stdout );
While (cin> k> p, k | p)
{
Int t, x;
Memset (g, false, sizeof (g ));
For (int I = 0; I <p; I ++)
{
Scanf ("% d", & t );
While (t --)
{
Scanf ("% d", & x );
G [I] [x] = true; // This person is connected to his/her spare time.
}
}
If (hungry () = k) // if yes
Printf ("yes \ n ");
Else
Printf ("no \ n ");
// Printf ("% d \ n", hungry ());
}
Return 0;
}