N opaque rectangles (1 ≤ N ≤ 1000) of various colors are placed on a white sheet of paper whose size is A wide by B long. The rectangles are put with their sides parallel to the sheet's borders. All rectangles fall within the borders of the sheet so that different figures of different colors will be seen.
The coordinate system has its origin (0, 0) at the sheet's lower left corner with axes parallel to the sheet's borders.
The order of the input lines dictates the order of laying down the rectangles. The first input line is a rectangle “on the bottom”.
First line contains A, B and N, space separated (1 ≤ A, B ≤ 10000).
Lines 2, …, N + 1 contain five integers each: llx, lly, urx, ury,
color: the lower left coordinates and upper right coordinates of the
rectangle whose color is color (1 ≤ color ≤ 2500) to be placed
on the white sheet. The color 1 is the same color of white as the sheet
upon which the rectangles are placed.
The output should contain a list of all the colors that can be seen along with the total area of each color that can be seen (even if the regions of color are disjoint), ordered by increasing color. Do not display colors with no area.
20 20 3
2 2 18 18 2
0 8 19 19 3
8 0 10 19 4