#K71782. Grid Operations

    ID: 33608 Type: Default 1000ms 256MiB

Grid Operations

Grid Operations

You are given a 2-dimensional grid with ( R ) rows and ( C ) columns. Initially, every cell of the grid contains ( 0 ). You need to perform ( Q ) operations on the grid. Each operation is one of the following three types:

  1. Row Update: The operation is given as:
    (1\ r\ v): Set every value in row ( r ) to ( v ).

  2. Column Update: The operation is given as:
    (2\ c\ v): Set every value in column ( c ) to ( v ).

  3. Rectangle Update: The operation is given as:
    (3\ r_1\ c_1\ r_2\ c_2\ v): Set every value in the subgrid, where the top-left coordinate is ( (r_1,c_1) ) and the bottom-right coordinate is ( (r_2,c_2) ) (inclusive), to ( v ).

After executing all operations, output the final grid configuration. The grid rows are indexed from ( 0 ) to ( R-1 ) and the columns from ( 0 ) to ( C-1 ).

inputFormat

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

The first line contains three integers ( R ), ( C ), and ( Q ) separated by spaces, denoting the number of rows, columns, and the number of operations, respectively.

Each of the next ( Q ) lines describes an operation. An operation can have one of the following formats:

  • For a row update: 1 r v
  • For a column update: 2 c v
  • For a rectangle update: 3 r1 c1 r2 c2 v

It is guaranteed that the indices provided are within bounds.

outputFormat

Print the final configuration of the grid to standard output (stdout). Each of the ( R ) lines should contain ( C ) integers separated by a space representing one row of the grid.## sample

4 5 3
1 2 3
2 1 4
3 0 0 1 1 5
5 5 0 0 0

5 5 0 0 0 3 4 3 3 3 0 4 0 0 0

</p>