Dance Party
题号:NC225908
时间限制:C/C++/Rust/Pascal 4秒,其他语言8秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
Special Judge, 64bit IO Format: %lld

题目描述

ZYB plans to hold a dance party and has invited ladies and gentlemen, they are both numbered from to . Now ZYB wants to match the lady and gentleman one by one.

However, each lady holds a blacklist that she wouldn't like to dance with the man on that list. For the -th lady, she lists k_i gentlemen and their IDs are  repectively.

ZYB wonders whether there exists a perfect matching so that each lady can dance without her dislike.

输入描述:

The first line of input contains one integer , indicating the number of ladies and gentlemen invited.

In the next following  lines, there is a integer  first, indicating the number of gentlemen that the -th lady dislikes. Then followed with k_i integers .

输出描述:

You should output  integers if there exists a perfect matching, the -th number indicating the gentleman ID that the -th lady chooses. Please output  if no such matching exists.
示例1

输入

复制
3
1 1
1 2
1 3

输出

复制
2 3 1
示例2

输入

复制
3
1 1
2 2 3
2 2 3

输出

复制
-1