import java.util.Collections;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int N = in.nextInt();//问题数
            int[] askId = new int[N];//提问人ID
            int[] ansNum = new int[N];//回答人的人数
            int[][] map = new int[N + 1][N + 1];
            for (int i = 0; i < N; i++) {
                askId[i] = in.nextInt();
                ansNum[i] = in.nextInt();
                for (int j = 0; j < ansNum[i]; j++) {//具体回答问题的人的ID
                    int ansId = in.nextInt();
                    //map[i][j] = 1:j回答了i的问题。最后map长度为n,宽度为ansNum[i],每一行的宽度可能不一样
                    map[askId[i]][ansId] = 1;
                }
            }
            //判断是否作弊
            List<Integer> list = new ArrayList<>();//作弊清单
            for (int i = 0; i <= N; i++) {
                int count = 0;//对于每一个用户,记录作弊的人数
                for (int j = 0; j <= N; j++) {
                    if (map[i][j] == 1 && map[j][i] == 1 &&
                            i != j) {//两人互相回答了对方的问题
                        if (!list.contains(i)) {//加入清单,如果已存在就不重复添加了
                            list.add(i);
                            count++;
                        }
                    }
                    if (map[i][j] == 1 && i != j &&
                            list.contains(j)) {//作弊用户回答了i的问题,i也判为作弊
                        count++;
                    }
                    if (count >=
                            2) {//对于每一个用户,如果回答人数超过2个,且这两个人都作弊了,那么这个人也判作弊
                        if (!list.contains(i)) {
                            list.add(i);
                        }
                    }
                }
            }
            Collections.sort(list);
            if (list.size() == 0) {
                System.out.println(0);
            } else {
                System.out.println(list.size());
                for (int i = 0; i < list.size(); i++) {
                    System.out.print(list.get(i) + " ");
                }
                System.out.println();
            }
        }
    }
}