Get to Work (Small)

No attempts yetTime limit5sMemory limit512 MB

Problem

A company has its office in town TT and employs EE people. There are NN towns in the area, and every employee lives in one of them.

Some employees drive. Each employee comes with an integer PP. If PP is 00, that employee has no license and cannot drive. If PP is at least 11, the car that employee drives holds PP people counting the driver, so P=1P = 1 means the driver takes only themselves to work.

The only way an employee moves between towns is in an employee's car, and an employee rides only with a driver who lives in the same town. An employee who lives in town TT is already in the town with the office and needs no car.

Decide whether every employee can reach town TT. If they can, choose the drivers so that the number of cars on the road is as small as possible, and find how many cars leave each town.

Input

The first line contains the number of test cases CC.

Each test case is given as follows.

  • One line with the number of towns NN and the number TT of the town where the office is.
  • One line with the number of employees EE.
  • EE lines describing one employee each. Each line has the number HH of the town that employee lives in and the capacity PP of the car that employee drives.

1C501 \le C \le 50, 1N101 \le N \le 10, 1TN1 \le T \le N, 1E1001 \le E \le 100, 1HN1 \le H \le N, 0P60 \le P \le 6.

Output

Print one line per test case, in the order the test cases are given. Each line starts with Case #X: , where X is the number of the test case counting from 11. After that print one of the following.

  • IMPOSSIBLE, if there are not enough drivers for every employee to reach the office.
  • If every employee can reach the office, print NN integers separated by one space, the number of cars leaving town 11 through town NN when the total number of cars is minimal. The value for town TT is always 00.