A specialist in VLSI design testing must decide if there are some components that cover each other for a given design. A component is represented as a rectangle. Assume that each rectangle is rectilinearly oriented (sides parallel to the x and y axis), so that the representation of a rectangle consists of its minimum and maximum x and y coordinates.
Write a program that counts the rectangles that are entirely covered by another rectangle.

The input contains the text description of several sets of rectangles. The specification of a set consists of the number of rectangles in the set and the list of rectangles given by the minimum and maximum x and y coordinates separated by white spaces, in the format:
nr_rectangles
xmin1 xmax1 ymin1 ymax1
xmin2 xmax2 ymin2 ymax2
...
xmin_{n} xmax_{n} ymin_{n} ymax_{n}
For each set,there will be less than 5000 rectangles.

The output should be printed on the standard output. For each given input data set, print one integer number in a single line that gives the result (the number of rectangles that are covered).

提交代码