Adrian the is a wizard prince. On International Wizard’s Day ( of November) he wanted to impress Norela, his dream girl. He has playing cards, which are initially put with the face down on a table. Adrian can use spells, a spell has the format: . If Adrian uses a spell, the playing cards with the indices will be turned in order. (Integers 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 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 and .
The next lines contain the description of every spell , where is the number of cards that will be turned by that spell and 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 is lexicographically smaller than other set if there is a between and so that and .
# | Points | Restrictions |
---|---|---|
1 | 20 | |
2 | 30 | |
3 | 25 | |
4 | 25 |
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 , and (, and ) will turn all cards face up.
It can be observed that another solution that turns all cards face up is , and , but this one is lexicographically bigger.