Storehouse

No attempts yetTime limit1sMemory limit128 MB

Problem

Advanced Cargo Movement, Ltd. owns a large storehouse in which many kinds of goods are stored. The storehouse has a limited number of bays where cargo can be loaded. Each day, trucks come to the bays, load their cargo (each truck loads exactly one type of goods), and leave for the shops. To speed up loading, the storekeepers move the goods to a bay in advance. Because the exact quantity of cargo to be loaded is not known beforehand, they prepare more goods than needed and return the leftover goods to the store afterwards. It is therefore convenient when the next truck at a bay loads the same type of goods as the previous one, since it avoids moving cargo unnecessarily. A truck's capacity is much smaller than a bay's, so any number of trucks can be served from one bay without reloading, as long as they all want the same type of goods.

Your task is to decide which type of goods is prepared in which bay so that the storekeepers move goods back to the storehouse as few times as possible. At the start of each day, no goods are prepared in any bay. Goods left in the bays at the end of the day are not counted toward the number of moves.

Input

The first line of the input contains the number of test cases to solve.

Each test case starts with a line containing three integers $B$, $G$, $N$ ($1 \le B \le 1000$, $1 \le G \le 1000000$, $1 \le N \le 1000000$) separated by single spaces. $B$ is the number of bays in the storehouse, $G$ is the number of types of goods stored, and $N$ is the number of trucks coming to the storehouse. The test case continues with $N$ lines; the $i$-th line contains an integer $t_i$ ($1 \le t_i \le G$), the type of goods the $i$-th truck wants to load, given in arrival order.

Output

When a truck arrives wanting a type of goods that is not currently prepared in any bay, that type must be moved into some bay before the truck is served; this counts as one LOAD action, and whatever was in that bay is returned to the storehouse. If the wanted type is already in a bay, no action is needed. Trucks are served one at a time in arrival order.

For each test case, output a single line

Case X: M

where X is the test case number (starting from 1) and M is the minimum possible number of LOAD actions needed to serve all trucks in that test case.