Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register
Language:
Storehouse
 Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 390 Accepted: 122 Special Judge

Description

Your task is to organize which type of goods will be prepared in which bay, so that storekeepers must move the unloaded goods back to the storehouse as few times as possible. At the beginning of each day, no goods is prepared in any bay. The goods left in bays at the end of the day is not counted to the number of moves needed.

Input

The first line of the input contains the number of test cases to solve. Each test case starts with the line containing three integer numbers, B, G, N, 1 <= B <= 1 000, 1 <= G <= 1 000 000, 1 <= N <= 1 000 000, separated by a single space. B is the number of bays in the storehouse, G the number of types of goods stored in the storehouse and N the number of trucks coming to the storehouse. The test case continues by N lines. On the i-th line, there is a number ti, 1 <= ti <= G, specifying the type of goods the i-th truck wants to load.

Output

For each test case, your program should output "Case X:" on the first line, where X is the case number starting with one. Then N lines follow. For each i, 1 <= i <= N, the i-th line must contain one of the following strings:
"NO ACTION" -- when no action needs to be performed before the arrival of the truck i(i.e., the goods i-th truck wants to load is already at some bay), or
"LOAD b g" -- when the goods with number g should be moved to the bay b before the i-th truck arrives. The goods currently present at the bay b is automatically moved back to the storehouse.
Each time some truck arrives, the goods it wants to load must be prepared at some bay. Assume that any truck leaves the bay before the next one arrives, i.e., only a single truck is served at a time.

The number of "LOAD" actions should be as small as possible. If there are more solutions with the same number of "LOAD" actions, choose any one you want. Outputs for different test cases should be separated by a blank line.

Sample Input

```2
2 4 5
1
2
1
4
1
3 3 3
1
3
2
```

Sample Output

```Case 1:
NO ACTION
NO ACTION

Case 2: