#P3397. 地毯

地毯

Description

On an n×nn \times n grid, there are mm carpets. Given the information of these carpets, determine how many carpets cover each cell.

Input Format

The first line contains two positive integers n,mn, m, as described above. Then follow mm lines. Each line gives two coordinates (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2), representing a carpet whose top-left corner is (x1,y1)(x_1,y_1) and bottom-right corner is (x2,y2)(x_2,y_2).

Output Format

Output nn lines, each containing nn non-negative integers. The integer in row ii and column jj denotes how many carpets cover the cell (i,j)(i,j).

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

Hint

Sample Explanation

After covering the first carpet:

00
00 11 00
00

After covering the first and second carpets:

00
00 11 11 00
22 11
00 11

After covering all carpets:

00 11 00
00 11 11 00
22 11
00 11

Constraints

For 20%20\% of the testdata, n50n \le 50, m100m \le 100. For 100%100\% of the testdata, n,m1000n, m \le 1000.

Translated by ChatGPT 5