Chess#5177

Chess

1 segundo
64 megabytes
Muy difícil

Petryk and Vasylko are playing a game on a chessboard with dimensions n \times m. Vasylko starts by placing bishops on the board in any configuration. Petryk's task is to place rooks on the remaining empty squares, ensuring that no two rooks can attack each other and that no rook is attacked by a bishop.

Your goal is to help Petryk place the maximum number of rooks possible.

Entrada

The first line contains two integers and (1 \le n, m \le 100), representing the number of rows and columns of the chessboard. The second line contains an integer (0 \le k \le n \cdot m), indicating the number of bishops on the board. The next lines each contain two integers, specifying the row and column positions of each bishop.

Salida

On the first line, output the maximum number of rooks that Petryk can place. On the subsequent lines, provide the positions of these rooks in the same format as the input.

Ejemplos

Ejemplo 1

Loading
Loading