시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 512 MB43266.667%

문제

You are given an integer $n$ and a number of non-empty sets of elements from $0$ to $n-1$.

Construct a permutation $p$ of length $n$, such that for every given set $S$ the following holds: $$\max_{s \in S} p_s - \min_{s \in S} p_s = |S| - 1\text{.}$$

The solution is guaranteed to exist. If there are multiple solutions output any.              

입력

The first line contains two integers $n$ and $m$ ($3 \leq n \leq 100, 1 \leq m \leq 100$), length of the permutation and the number of sets.

$m$ lines follow. $i$-th of them contains an integer $k_i$ ($2 \leq k_i < n$) followed by $k_i$ integers $a_{i,j}$ ($0 \leq a_{i,j} < n, a_{i,j}<a_{i,j+1}$), size of the $i$-th set and its elements themselves.

It is guaranteed that the given sets are pairwise distinct and the answer exists.                 

출력

Print $n$ integers. $i$-th of them should be equal to $p_i$.

예제 입력 1

3 1
2 0 1

예제 출력 1

0 1 2

예제 입력 2

8 5
3 4 5 7
3 2 3 6
3 2 5 7
2 4 5
2 1 6

예제 출력 2

7 6 3 4 0 1 5 2