#C5002. Flip the Subrectangle

    ID: 48604 Type: Default 1000ms 256MiB

Flip the Subrectangle

Flip the Subrectangle

You are given an m x n grid initially filled with zeros. You will be given k queries, each describing a subrectangle within the grid by four integers r1, c1, r2, c2 (1-indexed). For each query, you are required to flip the bits (i.e. change 0 to 1 and 1 to 0) in the subrectangle defined by the top-left coordinate (r1, c1) and bottom-right coordinate (r2, c2). After processing all queries, output the final state of the grid.

The flipping operation for any cell is defined as follows:

\[ \text{new_value} = 1 - \text{old_value}, \]

where initially \(\text{old_value} = 0\) for all cells.

Note: The coordinates provided in the queries are 1-indexed.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains three integers m, n, and k separated by spaces, representing the number of rows, number of columns, and the number of queries, respectively.
  • The next k lines each contain four integers r1, c1, r2, c2 separated by spaces, representing a query to flip the subrectangle defined by these coordinates.

outputFormat

The output is written to stdout and should be the final state of the grid after all queries have been performed. Each row of the grid should be printed on a new line with the cells separated by a single space.

## sample
3 3 2
1 2 2 3
2 1 3 2
0 1 1

1 0 1 1 1 0