#C11341. Incrementing Subgrid in a Grid

    ID: 40647 Type: Default 1000ms 256MiB

Incrementing Subgrid in a Grid

Incrementing Subgrid in a Grid

You are given a grid of size \( n \times n \) initialized with zeros. You are also given \( q \) queries. Each query contains four integers \( x_1, y_1, x_2, y_2 \) that represent the top-left and bottom-right coordinates of a subgrid (1-indexed). For every query, increment each cell in the specified subgrid by 1.

Note: Coordinates are 1-indexed. That is, the top-left cell of the grid is at position (1,1) and the bottom-right cell is at (n,n).

Examples:

  • For \( n = 4, q = 3 \) and queries: (1, 1, 2, 2), (2, 2, 3, 3), (1, 3, 4, 4), the final grid is:
    1 1 1 1
    1 2 2 1
    0 1 2 1
    0 0 1 1
        
  • For \( n = 2, q = 1 \) and query: (1, 1, 2, 2), the final grid is:
    1 1
    1 1
        
  • For \( n = 3, q = 0 \), the grid remains all zeros.
  • For \( n = 3, q = 1 \) and query: (1, 1, 3, 3), the final grid is:
    1 1 1
    1 1 1
    1 1 1
        

inputFormat

The first line contains two integers \( n \) and \( q \) separated by a space.

The next \( q \) lines each contain four integers \( x_1\), \( y_1\), \( x_2\), \( y_2 \) describing a query.

If \( q = 0 \), then there are no further lines.

outputFormat

Output the resulting \( n \times n \) grid after performing all queries. Each row of the grid should be printed on a new line with the values separated by a space.

## sample
4 3
1 1 2 2
2 2 3 3
1 3 4 4
1 1 1 1

1 2 2 1 0 1 2 1 0 0 1 1

</p>