KNCB - Knights in Chessboard

Giới hạn
  • Thời gian: 2.0s
  • Bộ nhớ: 1536MB
  • Mã nguồn: 50000 bytes

Ghi chú: Các bài VNOI đã được chuyển qua VNOJ (Thông báo). Đề bài trên VNOI và vn.spoj.com sẽ không được cập nhật nữa. Một số đề bài không chính xác sẽ chỉ được cập nhật trên VNOJ. Bạn vẫn có thể tìm kiếm đề bài trên VNOI.

Link đọc đề trên VNOJ

Given an m x n chessboard where some of the cells are broken. Now you are about to place chess knights in the chessboard. You have to find the maximum number of knights that can be placed in the chessboard such that no two knights attack each other. You can't place knights in the broken cells.

Those who are not familiar with chess knights, note that a chess knight can attack eight positions in the board as shown in the picture below.

Input

Input starts with an integer T (≤ 125), denoting the number of test cases.

Each case starts with a blank line. The next line contains three integers m, n, K (1 ≤ m, n ≤ 200). Here m and n corresponds to the number of rows and the number of columns of the board respectively. Each of the next Klines will contain two integers x, y (1 ≤ x ≤ m, 1 ≤ y ≤ n) denoting that the cell(x, y) is broken already. No broken cell will be reported more than once.

Output

For each case of input, print the case number and the maximum number of knights that can be placed in the board considering the above restrictions.

Sample Input
2

8 8 0

2 5 4
1 3
1 4
2 3
2 4

Sample Output
Case 1: 32
Case 2: 6


  • Người up: racer