norela

Time limit: 0.15s Memory limit: 512MB Input: Output:

Adrian the 3rd3^{\text{rd}} is a wizard prince. On International Wizard’s Day (4th4^{\text{th}} of November) he wanted to impress Norela, his dream girl. He has nn playing cards, which are initially put with the face down on a table. Adrian can use mm spells, a spell has the format: q a1 a2  aqq \ a_1 \ a_2 \ \dots \ a_q. If Adrian uses a spell, the playing cards with the indices a1 a2  aqa_1 \ a_2 \ \dots \ a_q will be turned in order. (Integers a1 a2  aqa_1 \ a_2 \ \dots \ a_q are all different). The card will be turn face up if it is face down and will be turned face down if it is face up and all spells can be used no more than one time. Help Adrian impress Norela before his nemesis Manea Long Eyebrow does it!

Task

Find the minimum number of spells that have to be used to turn all nn cards face up, also determinate the indices of the used spells. If there are more solutions, print the minimum lexicographical answer.

Input

The first line contains two integers nn and mm.

The next mm lines contain the description of every spell q a1 a2 aqq \ a_1 \ a_2 \ \dots a_q, where qq is the number of cards that will be turned by that spell and a1 a2  aqa_1 \ a_2 \ \dots \ a_q are the indices of those cards.

Output

The first line will contain only one integer representing the minimum number of used spells and the second line will contain the indices of those spells. If there are more solutions with minimum number of used spells, there will be printed the minimum lexicographical answer.

Restrictions

  • A set of integers a1 a2  ana_1 \ a_2 \ \dots \ a_n is lexicographically smaller than other set b1 b2  bnb_1 \ b_2 \ \dots \ b_n if there is a kk between 11 and nn so that a1=b1,a2=b2,..,ak1=bk1a_1=b_1 , a_2=b_2 ,.. , a_{k-1} = b_{k-1} and ak<bka_k < b_k.
# Points Restrictions
1 20 n40,m18n \leq 40, m \leq 18
2 30 n50,m21n \leq 50, m \leq 21
3 25 n60,m22n \leq 60, m \leq 22
4 25 n60,m24n \leq 60, m \leq 24

Example

stdin

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

stdout

3
1 2 3

Explanation

Using the spells with indices 11,22 and 33 (1 3 41 \ 3 \ 4, 3 53 \ 5 and 2 32 \ 3) will turn all cards face up.

It can be observed that another solution that turns all cards face up is 11,44 and 55, but this one is lexicographically bigger.

Log in or sign up to be able to send submissions!