PACKRECT - Packing Rectangles

no tags 

Four rectangles are given. Find the smallest enclosing (new) rectangle into which these four may be fitted without overlapping. By smallest rectangle, we mean the one with the smallest area.

All four rectangles should have their sides parallel to the corresponding sides of the enclosing rectangle.

Rectangles may be rotated 90 degrees during packing.

There may exist several different enclosing rectangles fulfilling the requirements, all with the same area. You must produce all such enclosing rectangles.

Input

Four lines, each containing two positive space-separated integers that represent the lengths of a rectangle's two sides. Each side of a rectangle is at least 1 and at most 50.

Output

The output file contains one line more than the number of solutions. The first line contains a single integer: the minimum area of the enclosing rectangles. Each of the following lines contains one solution described by two numbers p and q with p<=q. These lines must be sorted in ascending order of p, and must all be different.

Example

Input:
1 2
2 3
3 4
4 5

Output:
40
4 10
5 8

hide comments
:D: 2012-08-11 10:39:29

No "try it now". If you changed something in the test data rejudge all the submissions. Or did you change the description?

Re:
I already rejudged all the submissions...anyways just one submission was there, so i asked to try it

Re Re:
Ok, I may have been looking on another problem's submission list. Anyway thanks for fixing the issues.

Last edit: 2012-08-11 16:35:15
(Tjandra Satria Gunawan)(曾毅昆): 2012-08-11 09:35:09

Why my solution that got AC in UASCO training gate getting WA here? Is there something wrong with your test data? Please give me a test case that cause my program wrong: ID=7445793

Try it now..

Last edit: 2012-08-11 09:44:02

Added by:nhs
Date:2012-08-10
Time limit:0.100s-1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:IOI 95