cho.sh
Notes
Loading...

Confining the Black Goat

Time limit

2s

Memory limit

128 MB

Problem

Among a captured group of young goats, one black goat is especially troublesome, so it must be isolated from the others. On a flat hill there are N rectangular fences. The fence segments never overlap or touch each other. However, one fence may completely surround another.

Because the black goat is clever and good at escaping, you want to place it in a region enclosed by as many fences as possible. Find the maximum number of fences that can enclose the goat, and the number of regions where that maximum is attained.

Input

The first line contains the number of fences N. (1 ≤ N ≤ 250,000)

Each of the next N lines contains one fence in the form X1 Y1 X2 Y2. (X1, Y1) is the upper-left corner and (X2, Y2) is the lower-right corner. Every coordinate is an integer from 1 to 1,000,000,000 inclusive, and X1 < X2, Y1 < Y2.

Output

Print two integers on the first line. The first is the maximum number of fences that can enclose one position, and the second is the number of regions where that maximum is attained.

Hint

The third fence is inside both the first and second fences, so the black goat can be placed inside at most 3 fences. Only one region attains this depth.