# 2184. Milkshakes

You own a milkshake shop. There are N different flavors that you can prepare, and each flavor can be prepared “malted” or “unmalted”. So, you can make 2N different types of milkshakes.

Each of your customers has a set of milkshake types that they like, and they will be satisfied if you have at least one of those types prepared. At most one of the types a customer likes will be a “malted” flavor.

You want to make N batches of milkshakes, so that:

1.There is exactly one batch for each flavor of milkshake, and it is either malted or unmalted.

2.For each customer, you make at least one milkshake type that they like.

3.The minimum possible number of batches are malted.

Find whether it is possible to satisfy all your customers given these constraints, and if it is, what milkshake types you should make.

If it is possible to satisfy all your customers, there will be only one answer which minimizes the number of malted batches

### 输入格式

1.One line containing an integer C, the number of test cases in the input file.

For each test case, there will be:

2.One line containing the integer N, the number of milkshake flavors.

3.One line containing the integer M, the number of customers.

4.M lines, one for each customer, each containing:

(1) An integer T >= 1, the number of milkshake types the customer likes, followed by

(2) T pairs of integers “X Y”, one for each type the customer likes, where X is the milkshake flavor between 1 and N inclusive, and Y is either 0 to indicate unmalted, or 1 to indicated malted. Note that:

<1>No pair will occur more than once for a single customer.

<2>Each customer will have at least one flavor that they like (T >= 1).

<3>Each customer will like at most one malted flavor. (At most one pair for each customer has Y = 1).

All of these numbers are separated by single spaces.

C = 5

1 <= N <= 2000

1 <= M <= 2000

### 输出格式

C lines, one for each test case in the order they occur in the input file, each containing the string “Case #X: ” where X is the number of the test case, starting from 1, followed by:

The string “IMPOSSIBLE”, if the customers’ preferences cannot be satisfied; OR

N space-separated integers, one for each flavor from 1 to N, which are 0 if the corresponding flavor should be prepared unmalted, and 1 if it should be malted

### 样例

Input
2
5
3
1 1 1
2 1 0 2 0
1 5 0
1
2
1 1 0
1 1 1

Output
Case #1: 1 0 0 0 0
Case #2: IMPOSSIBLE
Hint:
In the first case, you must make flavor #1 malted, to satisfy the first customer. Every other flavor can be unmalted. The second customer is satisfied by getting flavor #2 unmalted, and the third customer is satisfied by getting flavor #5 unmalted.
In the second case, there is only one flavor. One of your customers wants it malted and one wants it unmalted. You cannot satisfy them both.


1 人解决，19 人已尝试。

1 份提交通过，共有 42 份提交。

9.9 EMB 奖励。