#P6126. [JSOI2012] 始祖鸟

    ID: 5101 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2012各省省选江苏Special Judge高斯消元异或方程组

[JSOI2012] 始祖鸟

Description

Recently, an “Archaeopteryx Specialty Store” appeared in the Jinxian River area, but this is not just a sudden whim.

As early as ancient times, the Jinxian River area attracted flocks of Archaeopteryx with its beautiful environment and suitable temperature. Archaeopteryx are a united kind of bird. They always use various ways to strengthen communication within the group, and gatherings are one of them. Because gatherings can not only strengthen friendships between friends, but also help them meet new friends.

Now there are NN Archaeopteryx, numbered from 11. For the ii-th Archaeopteryx, it has MiM_i friends it knows, whose indices are Fi,1,Fi,2,,Fi,MiF_{i,1},F_{i,2},\dots,F_{i,M_i}. The “knowing” relationship is one-way, which means if the ss-th Archaeopteryx knows the tt-th Archaeopteryx, then the tt-th Archaeopteryx does not necessarily know the ss-th Archaeopteryx.

There are two gathering places: one upstream and one downstream. For each gathering place, it must satisfy that for every Archaeopteryx in that place, it has exactly an even number of friends it knows who are also in the same place. Of course, every Archaeopteryx must be in exactly one of the two gathering places.

Now you need to provide an arrangement. You only need to output the indices of the Archaeopteryx that are upstream. If there are multiple solutions, output any one of them.

Input Format

The input contains N+1N+1 lines. The first line is the integer NN, representing the number of Archaeopteryx.
In the next NN lines, on line i+1i+1, the first integer is MiM_i, representing the number of friends of the ii-th bird. Then there are MiM_i integers Fi,1,Fi,2,,Fi,MiF_{i,1},F_{i,2},\dots,F_{i,M_i}, representing the indices of the friends of the ii-th Archaeopteryx.

Output Format

The output contains 22 lines. The first line has a non-negative integer kk, representing the number of Archaeopteryx attending the gathering upstream. The second line has kk positive integers, representing the indices of these kk Archaeopteryx. You may output them in any order. If the requirement cannot be satisfied, output only one line Impossible.

5
3 2 3 4
2 1 3
4 2 1 4 5
2 1 3
1 3
3
1 2 3

Hint

Constraints

  • For 100%100\% of the testdata, 1N20001 \le N \le 2000.

Translated by ChatGPT 5