cho.sh
Notes
Loading...

Orchard

Time limit

2s

Memory limit

64 MB

Problem

A large field contains rectangular orchards. Different orchards do not overlap, although they may share a side. Each orchard contains exactly one kind of fruit, and several orchards may contain the same kind of fruit.

The figure below shows two fields viewed from above. Rectangles drawn with the same color represent orchards containing the same kind of fruit.

Find the maximum area of an axis-aligned rectangle that can be filled completely with one kind of fruit.

Input

The first line contains the number of orchards, N (1 <= N <= 2,500).

Each of the next N lines contains five integers X1, Y1, X2, Y2, and C, separated by spaces. Here X1 < X2 and Y1 < Y2, and the orchard is the rectangle whose opposite corners are (X1, Y1) and (X2, Y2).

All coordinates are integers between 0 and 1,000,000,000, inclusive. C is the number representing the kind of fruit planted in that orchard (1 <= C <= 100).

Output

Output the maximum area of an axis-aligned rectangle that is completely filled with one kind of fruit.