Preparando MOJI

Different variables

2000ms 262144K

Description:

N variables X1, ..., XN can have positive integer values. You are given K constraints for these value that look like "the values of variables Xi1, Xi2, ..., XiM are different". Among all possible lists of values of these variables that satisfy these constraints select the ones which have minimum possible max(Xi). Output lexicographically least of these lists.

Input:

The first line of input contains two integers n and k (2 ≤ N ≤ 10, 1 ≤ K ≤ 100) — the number of variables and the number of constraints.

The following K lines contain the constraints, formatted as follows: the first number in the line M (2 ≤ M ≤ N) gives the number of variables in the constraint. After it follow M space-separated integers i1, ..., iM — the indices of the variables used in the constraint (1 ≤ ij ≤ N). All ij in one constraint are different.

Output:

Output the values of X1, X2, ..., XN in a single line, separated with single spaces.

Sample Input:

2 1
2 1 2

Sample Output:

1 2

Sample Input:

3 2
2 1 2
2 2 3

Sample Output:

1 2 1

Informação

Codeforces

Provedor Codeforces

Código CF530I

Tags

*special

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 08:57:21

Relacionados

Nada ainda