Little Bunny loves to eat corns. Fortunately, he lives near an abandoned house which has a huge cornfield in the backyard. For some weird reason, all the corn plants are in a single row. Each plant has only one corn. Each corn has two important properties, length and quality.
Winter is coming and it’s time for him to collect the corns. Otherwise he will starve to death. Little Bunny has its own way to collect corns. There will be N corn plants. Little Bunny will start collecting the corns from 1 to N. Note that he can’t jump to a corn plant without collecting all the corns before it. Before collecting the corns he will grab a box. After picking a corn he can put it into the box if the box is empty or it fulfills all the following conditions.
After putting the corn into the box:
Input will start with a positive integer () denoting the number of test cases. Each test case will start with a positive integer () denoting the number of corn plants. Each of the following lines will have two integers , denoting the length and the quality of the -th corn, where and will fit into a 32-bit signed integer.
For each test case please output the answer as the following format, “Case t: b” without the quotations. Here is the case number and is the number of boxes of corns Little Bunny has at the end.
Input | Output |
---|---|
2 6 1 0 1 1 1 2 1 1 1 0 2 0 6 1 1 1 2 1 3 2 4 2 3 2 2 | Case 1: 1 Case 2: 2 |