import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] s = new int[n];
        Arrays.fill(s , 0);
        for(int i = 0 ; i < k ; i++){
            int d = sc.nextInt();
            int[] a = new int[d];
            for(int j = 0 ; j < d ; j++){
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } 
        }
        sc.close();
        Arrays.sort(s);
        int yono = 0;
        while(s[yono] == 0){
            yono++;
        }
        System.out.println(yono);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] s = new int[n];
        Arrays.fill(s , 0);
        for(int i = 0 ; i < k ; i++){
            int d = sc.nextInt();
            int[] a = new int[d];
            for(int j = 0 ; j < d ; j++){
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } 
        }
        sc.close();
        Arrays.sort(s);
        int yono = 0;
        while(s[yono] == 0){
            yono++;
        }
        System.out.println(yono);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] s = new int[n];
        Arrays.fill(s , 0);
        for(int i = 0 ; i < k ; i++){
            int d = sc.nextInt();
            int[] a = new int[d];
            for(int j = 0 ; j < d ; j++){
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } 
        }
        sc.close();
        Arrays.sort(s);
        int yono = 0;
        while(s[yono] == 0){
            yono++;
        }
        System.out.println(yono);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] s = new int[n];
        Arrays.fill(s , 0);
        for(int i = 0 ; i < k ; i++){
            int d = sc.nextInt();
            int[] a = new int[d];
            for(int j = 0 ; j < d ; j++){
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } 
        }
        sc.close();
        Arrays.sort(s);
        int yono = 0;
        while(s[yono] == 0){
            yono++;
        }
        System.out.println(yono);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc int[] s = new int[n]; s new int[n] n Arrays.fill(s , 0) Arrays.fill Arrays s 0 for(int i = 0 ; i < k ; i++){
            int d = sc.nextInt();
            int[] a = new int[d];
            for(int j = 0 ; j < d ; j++){
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } 
        } int i = 0 ; int i = 0 ; i 0 i < k i k i++ i++ i {
            int d = sc.nextInt();
            int[] a = new int[d];
            for(int j = 0 ; j < d ; j++){
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } 
        } {
            int d = sc.nextInt();
            int[] a = new int[d];
            for(int j = 0 ; j < d ; j++){
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } 
        } int d = sc.nextInt(); d sc.nextInt() sc.nextInt sc int[] a = new int[d]; a new int[d] d for(int j = 0 ; j < d ; j++){
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } int j = 0 ; int j = 0 ; j 0 j < d j d j++ j++ j {
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } {
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } a[j] = sc.nextInt() - 1 a[j] a j sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 s[a[j]]++ s[a[j]] s a[j] a j sc.close() sc.close sc Arrays.sort(s) Arrays.sort Arrays s int yono = 0; yono 0 while(s[yono] == 0){
            yono++;
        } s[yono] == 0 s[yono] s yono 0 {
            yono++;
        } yono++ yono System.out.println(yono) System.out.println System.out System System.out yono String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] s = new int[n];
        Arrays.fill(s , 0);
        for(int i = 0 ; i < k ; i++){
            int d = sc.nextInt();
            int[] a = new int[d];
            for(int j = 0 ; j < d ; j++){
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } 
        }
        sc.close();
        Arrays.sort(s);
        int yono = 0;
        while(s[yono] == 0){
            yono++;
        }
        System.out.println(yono);
    }
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] s = new int[n];
        Arrays.fill(s , 0);
        for(int i = 0 ; i < k ; i++){
            int d = sc.nextInt();
            int[] a = new int[d];
            for(int j = 0 ; j < d ; j++){
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } 
        }
        sc.close();
        Arrays.sort(s);
        int yono = 0;
        while(s[yono] == 0){
            yono++;
        }
        System.out.println(yono);
    }
} Main
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] s = new int[n];
        Arrays.fill(s , 0);
        for(int i = 0 ; i < k ; i++){
            int d = sc.nextInt();
            int[] a = new int[d];
            for(int j = 0 ; j < d ; j++){
                a[j] = sc.nextInt() - 1;
                s[a[j]]++;
            } 
        }
        sc.close();
        Arrays.sort(s);
        int yono = 0;
        while(s[yono] == 0){
            yono++;
        }
        System.out.println(yono);
    }
}