import java.io.*;
import java.util.*;
public class metro_ia implements Runnable {

	private Scanner in;
	private PrintWriter out;

	public void run() {
		try {
			solve();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	@SuppressWarnings("unchecked")
	private void solve() throws Exception {
		Locale.setDefault(Locale.US);
		in = new Scanner(new FileReader("metro.in"));
		out = new PrintWriter("metro.out");
		
		int k = in.nextInt();
		assertRange(k, 1, 10);
		
		int[] r1 = new int[k - 1];
		int[] r2 = new int[k - 1];
		int[] a = new int[k - 1];
		Arrays.fill(r1, -1);
		Arrays.fill(r2, -1);
		Arrays.fill(a, -1);
		
		int n = in.nextInt();
		int m = 0;
		
		int[][] s = new int[n][];
		
		for (int i = 0; i < n; i++) {
			int p = in.nextInt();
			myAssert(p >= 2);
			s[i] = new int[p];
			boolean ring = false;
			for (int j = 0; j < p; j++) {
				s[i][j] = in.nextInt();
				assertRange(s[i][j], 0, k - 1);
				if (s[i][j] == 0) {
					ring = true;
					myAssert(m == i);
					m++;
				}
			}
			for (int x : s[i]) if (x != 0) {
				if (ring) {
					if (r1[x - 1] == -1) {
						r1[x - 1] = i;
					} else {
						myAssert(r2[x - 1] == -1);
						r2[x - 1] = i;
					}
				} else {
					myAssert(a[x - 1] == -1);
					a[x - 1] = i;
				}
			}
		}
		
		int[] var = new int[k - 1];
		int[] type = new int[k - 1];
		for (int i = 0; i < k - 1; i++) {
			var[i] = 1;
			if ((r1[i] > -1) && (r2[i] > -1)) {
				if (a[i] > -1) {
					var[i] = 3;
					type[i] = 3;
				} else {
					type[i] = 1;
				}
			} else {
				if ((r1[i] > -1) && (a[i] > -1)) {
					type[i] = 2;
				} else {
					type[i] = 0;
				}
			}
		}
		
		int[] p = new int[k - 1];
		boolean can = false;
		
		ArrayList<Integer>[] f = new ArrayList[n];
		
		ArrayList<ArrayList<Integer>> stars = new ArrayList<ArrayList<Integer>>();
		while (true) {
			Arrays.fill(f, null);
			stars.clear();
			
			for (int i = 0; i < k - 1; i++) {
				if (type[i] == 1) {
					ArrayList<Integer> line = new ArrayList<Integer>();
					line.add(r1[i]);
					line.add(r2[i]);
					stars.add(line);
				} else if (type[i] == 2) {
					if (f[a[i]] == null) {
						f[a[i]] = new ArrayList<Integer>();
						stars.add(f[a[i]]);
					}
					ArrayList<Integer> star = f[a[i]];
					star.add(r1[i]);
				} else if (type[i] == 3) {
					if (f[a[i]] == null) {
						f[a[i]] = new ArrayList<Integer>();
						stars.add(f[a[i]]);
					}
					ArrayList<Integer> star = f[a[i]];
					if (p[i] == 1) {
						star.add(r1[i]);
						star.add(r2[i]);
					} else {
						ArrayList<Integer> line = new ArrayList<Integer>();
						line.add(r1[i]);
						line.add(r2[i]);
						stars.add(line);
						
						if (p[i] == 0) {
							star.add(r1[i]);
						} else {
							star.add(r2[i]);
						}
					}
				}
			}
			
			if (check(stars)) {
				can = true;
				break;
			}
			
			//GENNEXT
			int i = k - 2;
			while ((i >= 0) && (p[i] == var[i] - 1)) {
				p[i] = 0;
				i--;
			}
			if (i == -1) {
				break;
			}
			p[i]++;
		}
		
		out.println(can ? "YES" : "NO");
		
		in.close();
		out.close();
	}
	
	private boolean check(ArrayList<ArrayList<Integer>> stars) {
		for (ArrayList<Integer> star : stars) {
			Collections.sort(star);
		}
		
		int n = stars.size();
		boolean[][] s = new boolean[n][n];
		
		for (int i = 0; i < n; i++) {
			ArrayList<Integer> si = stars.get(i);
			for (int i1 = 0; i1 < si.size(); i1++) {
				int a = si.get(i1);
				for (int i2 = i1 + 1; i2 < si.size(); i2++) {
					int b = si.get(i2);

					for (int j = i + 1; j < n; j++) {
						ArrayList<Integer> sj = stars.get(j);
						for (int j1 = 0; j1 < sj.size(); j1++) {
							int c = sj.get(j1);
							for (int j2 = j1 + 1; j2 < sj.size(); j2++) {
								int d = sj.get(j2);
								if (((a < c) && (c < b) && (b < d)) || ((c < a) && (a < d) && (d < b))) {
									s[i][j] = true;
									s[j][i] = true;
								}
							}
						}
					}
				}
			}
		}
		
		
		int[] mark = new int[n];
		for (int i = 0; i < n; i++) {
			if (mark[i] == 0) {
				if (dfs(i, n, s, mark, 1)) {
					return false;
				}
			}
		}
		
		return true;
	}

	private boolean dfs(int u, int n, boolean[][] s, int[] mark, int x) {
		mark[u] = x;
		x = 3 - x;
		for (int v = 0; v < n; v++) if (s[u][v]) {
			if (mark[v] == 0) {
				if (dfs(v, n, s, mark, x)) {
					return true;
				}
			} else {
				if (mark[v] != x) {
					return true;
				}
			}
		}
		return false;
	}

	private void assertRange(int a, int l, int h) {
		myAssert((l <= a) && (a <= h));
	}

	private void myAssert(boolean b) {
		String msg = "ERROR IN TEST!!!";
		if (!b) {
			out.println(msg);
			System.out.println(msg);
			out.close();
			throw new Error(msg);
		}
	}

	public static void main(String[] args) {
		new Thread(new metro_ia()).start();
	}

}
