Time limit: 0.5 seconds Memory limit: 256 MB Pouyan is a chubby teenager who has decided…
- User
Time limit: 0.5 seconds Memory limit: 256 MB Pouyan is a chubby teenager who has decided to lose weight by working hard at a marble shop.
The shop where Pouyan works sells marbles n It offers n different sizes and each marble can be filled or not. So you can in this shop 2 n Found 2n different types of marbles.
dynamic shop m m has regular customers who visit the shop every day and look at the marbles. Each of these customers likes a bunch of marbles and if none of his favorite marbles are found in the store, he leaves the store upset. Also, if each of these customers likes a marble of one size, he will never like a marble of another size. (That is, among the favorite marbles of each customer, at most one of them is feathered.)
Pouyan wants to choose only one type (with or without feathers) of each marble size and continue to produce only it, without disturbing any of these fixed customers. It means that there must be at least one favorite marble of each of these customers in the production list. Meanwhile, Pouyan wants to minimize the number of feathered marbles in the production list.
By inputting the customer's interest list, if Pouyan can continue to produce marbles under the stated conditions and without upsetting his customers, output a state of the production list where the number of feathered marbles inside them is minimal.
input In the first line of the input number n n is said to represent the number of different sizes for the dynamic shop marbles.
In the second line of the input number m m is said to represent the number of fixed customers of the dynamic shop.
Then in i The i-th line of each of m m Next line, the list of types of marbles that the customer fixed i I like to be described. At the beginning of the number line k i k i It is said that it is equal to the number of marbles that this customer likes. then k i k i The type of marbles are described as two sizes and feathers. Normal and maximum equal numerical size n is n, and if feathered was equal to 1, it means that this customer likes marbles with feathers of this size, and if it was equal to 0, it means that he likes marbles without feathers of this size. (A customer may like both feathered and unfeathered marbles of the same size. This is stated in two different descriptions in this row. One for the feathered marble of this size and one for the unfeathered marble of this size.)
It is guaranteed that each customer likes at most one type of feather marble, and the same type of marble never appears twice in a customer's interest list.
1 ≤ n , m ≤ 2000 1≤n, m≤2000
1 ≤ k i ≤ 3000 1≤k i ≤3000
∑ i
1 m k i ≤ 3000 i=1 ∑ m k i ≤3000
output If the list of marbles cannot be selected without upsetting regular customers, the output should contain only the word IMPOSSIBLE.
If it is possible to choose a feathered or unfeathered type of any size so that customers are not upset, output a state of these selections that has the least number of feathered marbles. Only the output line should contain n Let n be a number, each of which is equal to 0 or 1. If i The i-th number was equal to 1, which means a marble with a size of i i in the given list will be produced from now on, and if it is equal to 0, it means a marble with the size i i in the given list will henceforth be generated without padding.
- Assistant