#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include <vector>
#include <algorithm>
using namespace std;

#define inpfile "metro.in"
#define outfile "metro.out"

const int KMAX = 25;

bool a[2*KMAX][2*KMAX];
vector<int> comp[2*KMAX];
int compn;
int col[KMAX];

vector<int> ring[KMAX];
int mid[KMAX];
int pos[KMAX];
vector<int> cross[KMAX];
int crossn;
int k,n;
int m; //number of ring stations
bool found;

void Init()
{
	freopen(inpfile,"r",stdin);
	freopen(outfile,"w",stdout);
}

void Out()
{
	exit(0);
}

bool Edge(int x, int y)
{
	int i,j,p,q;
	for (i = 0; comp[x][i] <= comp[y][0]; i++);

	if (i != 0) {
		p = comp[x][i-1];
		q = comp[x][i];
		for (j = 0; j < comp[y].size() - 1; j++)
			if ((comp[y][j] < p) || (comp[y][j] > q)) return true;
	} else {
		p = comp[x][0];
		q =	comp[x][comp[x].size() - 2];
		for (j = 0; j < comp[y].size() - 1; j++)
			if ((comp[y][j] > p) && (comp[y][j] < q)) return true;
	}

	return false;
}

bool cycle;

void Dfs(int x, int color)
{
	col[x] = color;

	int i;
	for (i = 1; i <= compn; i++)
		if( (comp[i].size() >= 2) && (i != x) && a[x][i]) {
			if (!col[i]) Dfs(i, 3 - color);
			else if (col[i] == color) {
				cycle = true;
				return;
			}

			if (cycle) return;
		}
}

void TryToSolve()
{
	memset(a,0,sizeof(a));
	int i,j;

	compn = crossn;
	for (i = 1; i < k; i++)
		if (mid[i]) {
			if (!pos[i]) {
				for (j = 0; j < ring[i].size(); j++)
					comp[mid[i]].push_back(ring[i][j]);
			} else {
				comp[mid[i]].push_back(ring[i][pos[i] - 1]);
				compn++;
				for (j = 0; j < ring[i].size(); j++)
					comp[compn].push_back(ring[i][j]);

				a[mid[i]][compn] = true;
				a[compn][mid[i]] = true;
			}
		} else {
			compn++;
			for (j = 0; j < ring[i].size(); j++)
				comp[compn].push_back(ring[i][j]);
		}

	memset(col,0,sizeof(col));
	for (i = 1; i <= compn; i++) 
		if (comp[i].size() >= 2) {
			sort(comp[i].begin(), comp[i].end());
			comp[i].resize(unique(comp[i].begin(), comp[i].end()) - comp[i].begin());
			comp[i].push_back(comp[i][0] + m);
		} else col[i] = 1;

	for (i = 1; i <= compn - 1; i++) if (!col[i])
		for (j = i + 1; j <= compn; j++) if (!col[j])
			if (!a[i][j]) {
				a[i][j] = Edge(i,j);
				a[j][i] = a[i][j];
			}
	
	cycle = false;
	for (i = 1; i <= compn; i++)
		if (!col[i]) {
			Dfs(i,1);
			if (cycle) break;
		}

	for (i = 1; i <= compn; i++) comp[i].clear();
}

void Rec(int h)
{
	if (h == k) {
		TryToSolve();
		if (!cycle) {
			found = true;
			return;
		}
		return;
	}

	if ((ring[h].size() == 2) && (mid[h])) {
		for (pos[h] = 0; pos[h] <= 2; pos[h]++) Rec(h + 1);
	} else Rec(h + 1);
}

void Solve()
{
	memset(pos,0,sizeof(pos));
	found = false;
	Rec(1);
	if (found) printf("YES\n");
	else printf("NO\n");
}

bool Inp()
{
	vector<int> list;
	int i,j,kol;
	int x;

	memset(mid,0,sizeof(mid));

	m = 0;
	if (scanf("%d %d",&k,&n) != 2) return false;

	for (i = 1; i <= k; i++) ring[i].clear();

	for (i = 1; i <= n; i++) {
		scanf("%d",&kol);
		list.clear();
		for (j = 1; j <= kol; j++) {
			scanf("%d",&x);
			list.push_back(x);
		}
		
		if (list[0] == 0) {
			m++;
			for (j = 1; j < list.size(); j++)
				ring[list[j]].push_back(i);
		} else {
			crossn++;
			cross[crossn].clear();
			for (j = 0; j < list.size(); j++) {
				mid[list[j]] = crossn;
				cross[crossn].push_back(list[j]);
			}
		}
	}

	return true;
}

int main()
{
	Init();
	while (Inp()) {
		Solve();
	}
	Out();
	return 0;
}
