Who Brings the Cookies?
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 32 M,其他语言64 M
64bit IO Format: %lld

题目描述

Farmer John's N (1 <= N <= 1,000) cows conveniently numbered 1..N decided to form M (1 <= M <= 100) study groups. A total of Si (1 <= Si <= 19) cows study in group G_i (namely cows , ...). A cow might study in more than one study group.
For each study group, one cow in the group must be chosen to bring cookies to the meeting. Cookies are costly and require time to acquire, so the cows want to divide the work of bringing cookies as fairly as possible.
They decided that if a cow attends meetings with size c1, c2, ..., cK, she is only willing to bring cookies to at most ceil(1/c1 + 1/c2 + ... + 1/cK) meetings.
Figure out which cow brings cookies to each meeting. If this isn't possible, just output '-1'. Choose any solution if more than one is possible.

输入描述:

* Line 1: Two space-separated integers: N and M
* Lines 2..M+1: Line i+1 contains many space-separated integers: , ...

输出描述:

* Lines 1..M: If a mapping is possible, line i contains the number of the cow who brings cookies to study group i. Otherwise, line 1 contains just the integer -1.
示例1

输入

复制
5 6 
3 2 4 5 
2 1 3 
3 1 2 3 
1 1 
2 2 5 
3 2 3 4 

输出

复制
4
3
1
1
2
2