import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String... args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String s = reader.readLine();
        String[] NM = s.split("\\s+");
        int N = Integer.parseInt(NM[0]);
        int M = Integer.parseInt(NM[1]);

        int bitset = 0;
        for (int i = 1; i <= M; i++) bitset |= 1 << i;

        for (int i = 0; i < N; i++) {
            int bits = 0;
            String[] split = reader.readLine().split("\\s+");
            for (int r = 1; r < split.length; r++) {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            }
            bitset &= bits;
        }

        bitset = (bitset & 0x55555555) + ((bitset & 0xAAAAAAAA) >>> 1);
        bitset = (bitset & 0x33333333) + ((bitset & 0xCCCCCCCC) >>> 2);
        bitset = (bitset & 0x0F0F0F0F) + ((bitset & 0xF0F0F0F0) >>> 4);
        bitset = (bitset & 0x00FF00FF) + ((bitset & 0xFF00FF00) >>> 8);
        bitset = (bitset & 0x0000FFFF) + ((bitset & 0xFFFF0000) >>> 16);
        System.out.println(bitset);
    }
} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {
    public static void main(String... args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String s = reader.readLine();
        String[] NM = s.split("\\s+");
        int N = Integer.parseInt(NM[0]);
        int M = Integer.parseInt(NM[1]);

        int bitset = 0;
        for (int i = 1; i <= M; i++) bitset |= 1 << i;

        for (int i = 0; i < N; i++) {
            int bits = 0;
            String[] split = reader.readLine().split("\\s+");
            for (int r = 1; r < split.length; r++) {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            }
            bitset &= bits;
        }

        bitset = (bitset & 0x55555555) + ((bitset & 0xAAAAAAAA) >>> 1);
        bitset = (bitset & 0x33333333) + ((bitset & 0xCCCCCCCC) >>> 2);
        bitset = (bitset & 0x0F0F0F0F) + ((bitset & 0xF0F0F0F0) >>> 4);
        bitset = (bitset & 0x00FF00FF) + ((bitset & 0xFF00FF00) >>> 8);
        bitset = (bitset & 0x0000FFFF) + ((bitset & 0xFFFF0000) >>> 16);
        System.out.println(bitset);
    }
} Main public static void main(String... args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String s = reader.readLine();
        String[] NM = s.split("\\s+");
        int N = Integer.parseInt(NM[0]);
        int M = Integer.parseInt(NM[1]);

        int bitset = 0;
        for (int i = 1; i <= M; i++) bitset |= 1 << i;

        for (int i = 0; i < N; i++) {
            int bits = 0;
            String[] split = reader.readLine().split("\\s+");
            for (int r = 1; r < split.length; r++) {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            }
            bitset &= bits;
        }

        bitset = (bitset & 0x55555555) + ((bitset & 0xAAAAAAAA) >>> 1);
        bitset = (bitset & 0x33333333) + ((bitset & 0xCCCCCCCC) >>> 2);
        bitset = (bitset & 0x0F0F0F0F) + ((bitset & 0xF0F0F0F0) >>> 4);
        bitset = (bitset & 0x00FF00FF) + ((bitset & 0xFF00FF00) >>> 8);
        bitset = (bitset & 0x0000FFFF) + ((bitset & 0xFFFF0000) >>> 16);
        System.out.println(bitset);
    } main {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String s = reader.readLine();
        String[] NM = s.split("\\s+");
        int N = Integer.parseInt(NM[0]);
        int M = Integer.parseInt(NM[1]);

        int bitset = 0;
        for (int i = 1; i <= M; i++) bitset |= 1 << i;

        for (int i = 0; i < N; i++) {
            int bits = 0;
            String[] split = reader.readLine().split("\\s+");
            for (int r = 1; r < split.length; r++) {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            }
            bitset &= bits;
        }

        bitset = (bitset & 0x55555555) + ((bitset & 0xAAAAAAAA) >>> 1);
        bitset = (bitset & 0x33333333) + ((bitset & 0xCCCCCCCC) >>> 2);
        bitset = (bitset & 0x0F0F0F0F) + ((bitset & 0xF0F0F0F0) >>> 4);
        bitset = (bitset & 0x00FF00FF) + ((bitset & 0xFF00FF00) >>> 8);
        bitset = (bitset & 0x0000FFFF) + ((bitset & 0xFFFF0000) >>> 16);
        System.out.println(bitset);
    } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader new BufferedReader(new InputStreamReader(System.in)) String s = reader.readLine(); s reader.readLine() reader.readLine reader String[] NM = s.split("\\s+"); NM s.split("\\s+") s.split s "\\s+" int N = Integer.parseInt(NM[0]); N Integer.parseInt(NM[0]) Integer.parseInt Integer NM[0] NM 0 int M = Integer.parseInt(NM[1]); M Integer.parseInt(NM[1]) Integer.parseInt Integer NM[1] NM 1 int bitset = 0; bitset 0 for (int i = 1; i <= M; i++) bitset |= 1 << i; int i = 1; int i = 1; i 1 i <= M i M i++ i++ i bitset |= 1 << i; bitset |= 1 << i bitset 1 << i 1 i for (int i = 0; i < N; i++) {
            int bits = 0;
            String[] split = reader.readLine().split("\\s+");
            for (int r = 1; r < split.length; r++) {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            }
            bitset &= bits;
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int bits = 0;
            String[] split = reader.readLine().split("\\s+");
            for (int r = 1; r < split.length; r++) {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            }
            bitset &= bits;
        } {
            int bits = 0;
            String[] split = reader.readLine().split("\\s+");
            for (int r = 1; r < split.length; r++) {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            }
            bitset &= bits;
        } int bits = 0; bits 0 String[] split = reader.readLine().split("\\s+"); split reader.readLine().split("\\s+") reader.readLine().split reader.readLine() reader.readLine reader "\\s+" for (int r = 1; r < split.length; r++) {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            } int r = 1; int r = 1; r 1 r < split.length r split.length split split.length r++ r++ r {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            } {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            } String num = split[r]; num split[r] split r bits |= 1 << Integer.parseInt(num) bits 1 << Integer.parseInt(num) 1 Integer.parseInt(num) Integer.parseInt Integer num bitset &= bits bitset bits bitset = (bitset & 0x55555555) + ((bitset & 0xAAAAAAAA) >>> 1) bitset (bitset & 0x55555555) + ((bitset & 0xAAAAAAAA) >>> 1) (bitset & 0x55555555) bitset 0x55555555 ((bitset & 0xAAAAAAAA) >>> 1) (bitset & 0xAAAAAAAA) bitset 0xAAAAAAAA 1 bitset = (bitset & 0x33333333) + ((bitset & 0xCCCCCCCC) >>> 2) bitset (bitset & 0x33333333) + ((bitset & 0xCCCCCCCC) >>> 2) (bitset & 0x33333333) bitset 0x33333333 ((bitset & 0xCCCCCCCC) >>> 2) (bitset & 0xCCCCCCCC) bitset 0xCCCCCCCC 2 bitset = (bitset & 0x0F0F0F0F) + ((bitset & 0xF0F0F0F0) >>> 4) bitset (bitset & 0x0F0F0F0F) + ((bitset & 0xF0F0F0F0) >>> 4) (bitset & 0x0F0F0F0F) bitset 0x0F0F0F0F ((bitset & 0xF0F0F0F0) >>> 4) (bitset & 0xF0F0F0F0) bitset 0xF0F0F0F0 4 bitset = (bitset & 0x00FF00FF) + ((bitset & 0xFF00FF00) >>> 8) bitset (bitset & 0x00FF00FF) + ((bitset & 0xFF00FF00) >>> 8) (bitset & 0x00FF00FF) bitset 0x00FF00FF ((bitset & 0xFF00FF00) >>> 8) (bitset & 0xFF00FF00) bitset 0xFF00FF00 8 bitset = (bitset & 0x0000FFFF) + ((bitset & 0xFFFF0000) >>> 16) bitset (bitset & 0x0000FFFF) + ((bitset & 0xFFFF0000) >>> 16) (bitset & 0x0000FFFF) bitset 0x0000FFFF ((bitset & 0xFFFF0000) >>> 16) (bitset & 0xFFFF0000) bitset 0xFFFF0000 16 System.out.println(bitset) System.out.println System.out System System.out bitset String... args args public class Main {
    public static void main(String... args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String s = reader.readLine();
        String[] NM = s.split("\\s+");
        int N = Integer.parseInt(NM[0]);
        int M = Integer.parseInt(NM[1]);

        int bitset = 0;
        for (int i = 1; i <= M; i++) bitset |= 1 << i;

        for (int i = 0; i < N; i++) {
            int bits = 0;
            String[] split = reader.readLine().split("\\s+");
            for (int r = 1; r < split.length; r++) {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            }
            bitset &= bits;
        }

        bitset = (bitset & 0x55555555) + ((bitset & 0xAAAAAAAA) >>> 1);
        bitset = (bitset & 0x33333333) + ((bitset & 0xCCCCCCCC) >>> 2);
        bitset = (bitset & 0x0F0F0F0F) + ((bitset & 0xF0F0F0F0) >>> 4);
        bitset = (bitset & 0x00FF00FF) + ((bitset & 0xFF00FF00) >>> 8);
        bitset = (bitset & 0x0000FFFF) + ((bitset & 0xFFFF0000) >>> 16);
        System.out.println(bitset);
    }
} public class Main {
    public static void main(String... args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String s = reader.readLine();
        String[] NM = s.split("\\s+");
        int N = Integer.parseInt(NM[0]);
        int M = Integer.parseInt(NM[1]);

        int bitset = 0;
        for (int i = 1; i <= M; i++) bitset |= 1 << i;

        for (int i = 0; i < N; i++) {
            int bits = 0;
            String[] split = reader.readLine().split("\\s+");
            for (int r = 1; r < split.length; r++) {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            }
            bitset &= bits;
        }

        bitset = (bitset & 0x55555555) + ((bitset & 0xAAAAAAAA) >>> 1);
        bitset = (bitset & 0x33333333) + ((bitset & 0xCCCCCCCC) >>> 2);
        bitset = (bitset & 0x0F0F0F0F) + ((bitset & 0xF0F0F0F0) >>> 4);
        bitset = (bitset & 0x00FF00FF) + ((bitset & 0xFF00FF00) >>> 8);
        bitset = (bitset & 0x0000FFFF) + ((bitset & 0xFFFF0000) >>> 16);
        System.out.println(bitset);
    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String... args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String s = reader.readLine();
        String[] NM = s.split("\\s+");
        int N = Integer.parseInt(NM[0]);
        int M = Integer.parseInt(NM[1]);

        int bitset = 0;
        for (int i = 1; i <= M; i++) bitset |= 1 << i;

        for (int i = 0; i < N; i++) {
            int bits = 0;
            String[] split = reader.readLine().split("\\s+");
            for (int r = 1; r < split.length; r++) {
                String num = split[r];
                bits |= 1 << Integer.parseInt(num);
            }
            bitset &= bits;
        }

        bitset = (bitset & 0x55555555) + ((bitset & 0xAAAAAAAA) >>> 1);
        bitset = (bitset & 0x33333333) + ((bitset & 0xCCCCCCCC) >>> 2);
        bitset = (bitset & 0x0F0F0F0F) + ((bitset & 0xF0F0F0F0) >>> 4);
        bitset = (bitset & 0x00FF00FF) + ((bitset & 0xFF00FF00) >>> 8);
        bitset = (bitset & 0x0000FFFF) + ((bitset & 0xFFFF0000) >>> 16);
        System.out.println(bitset);
    }
}