Prison for Zedd
Time limit2sMemory limit1024 MB
Pick six of the given rectangles to form the three face pairs of a box and report the largest possible volume, or -1 if no box can be built.
Statement
The Black Ranger found rectangular metal sheets of different sizes in the crater of an abandoned volcano. Sheet measures meters by meters.
Zordon asked the Black Ranger to build a prison for the evil general Zedd, and these sheets are a lucky find. The prison must be a rectangular box where each face is one whole sheet. The Ranger will take 6 of the sheets, assemble the box, and show it to Zordon. Sheets cannot be bent or cut, and no sheet used in the prison may stick out past the edges of the box.
A bigger prison is a safer prison, so the box must have the largest possible volume. Find the maximum volume of a box that can be assembled from these sheets.
Sheets may be rotated. For example, a 4 by 7 sheet and a 7 by 4 sheet are considered the same.
Input
The first line contains one integer , the number of metal sheets ().
Each of the next lines contains two integers and , the dimensions of the -th sheet ().
Output
Print one integer, the maximum volume of a rectangular box that can be assembled from these sheets.
If no box can be assembled, print .