#P9700. [GDCPC 2023] Peg Solitaire
[GDCPC 2023] Peg Solitaire
题目描述
is a single-player boardgame on a chessboard with rows and columns. Each cell of the chessboard either is empty, or contains a chesspiece. Initially, there are chesspieces on the chessboard.
During the game, the player can choose a chesspiece, jump it over an adjacent chesspiece into an empty cell, and finally remove the chesspiece which is jumped over. More precisely, let be the cell on the -th row and the -th column, the player can perform operations of the following four types.

Given the initial state of the chessboard, the player can perform the operations any number of times (including zero times). Calculate the minimum possible number of chesspieces remaining on the chessboard.
输入格式
There are multiple test cases. The first line of the input contains an integer () indicating the number of test cases. For each test case:
The first line contains three integers , and (, ) indicating the number of rows and columns of the chessboard and the initial number of chesspieces.
For the following lines, the -th line contains two integers and (, ) indicating that there is a chesspiece in the cell on the -th row and the -th column at the beginning. Except from these cells, all other cells are empty at the beginning. The positions of these cells contain no duplicate.
输出格式
For each test case output one line containing one integer indicating the minimum possible number of chesspieces remaining on the chessboard.
3
3 4 5
2 2
1 2
1 4
3 4
1 1
1 3 3
1 1
1 2
1 3
2 1 1
2 1
2
3
1
提示
The first sample test case is explained as follows.

For the second sample test case, as the chessboard does not contain empty cell at the beginning, the player cannot perform any operation.
For the third sample test case, as the chessboard has less than three cells, the player cannot perform any operation.