## DMOPC '20 Contest 4 P2 - Beautiful Grids

View as PDF

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Penelope is playing a game on an grid! Her grid currently contains s, while the rest of her grid cells contain s.

Penelope isn't sure she likes her grid though. Specifically, she is worried that her grid isn't beautiful. A grid is beautiful if every row sum and column sum are even.

Penelope is in a hurry to make her grid beautiful so she asks you: how can she make her grid beautiful? On each move, you can flip the value of a grid cell: from to or to . Since she is in a hurry, she asks you to make her grid beautiful as fast as possible.

#### Constraints

All cells given are distinct.

#### Input Specification

The first line contains integers, , the number of rows; , the number of columns; and .

The next lines each contain two integers and , indicating that the cell in the row, column contains a .

#### Output Specification

On the first line output , the minimum number of moves required to make the grid beautiful. must satisfy . It can be proven that the minimum lies within this range.

On the next lines, output two space-separated integers and , indicating that you will flip the cell in the row, column.

You may output any valid sequence.

Note: your output must follow the standard convention of not having any extra whitespace, and it must end with a new line.

#### Scoring

If you output an incorrect value , but a valid sequence of moves, you will receive for that test case.

If you output a correct value , but an invalid sequence of moves, you will receive for that test case.

If you output a correct value of and any valid sequence of moves, you will receive for that test case.

Your score for a subtask will be the minimum score across all test cases of that subtask.

#### Sample Input

2 3 3
1 1
1 3
2 1

#### Sample Output

1
2 3

#### Explanation

Note that after our operation, our grid is:

1 0 1
1 0 1

which satisfies the constraints.