Rectangular Roundup


Submit solution

Points: 1
Time limit: 1.5s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python

Patricks problemsetting minions keep getting distracted and running away, so there is no Div B problems ready in time! He wants to place them in a rectangular pen so that they can focus and get more work done.

Given the positions of n helpers, Patrick wants to find the smallest axis-aligned rectangle that contains all of them. This means the edges must be parallel to the x and y axis, and we are looking to minimise the width, and then minimise the height if there are ties. Moreover, minions on the boundary of a rectangle are said to be contained in it.

Can you help Patrick find the corners of this rectangle to increase AUCPL efficiency?

Input

The first line contains an integer n (1 \leq n \leq 10^5), the number of minions Patrick wants to enclose.

The next n lines each contain two integers x_i\ y_i (-10^9 \leq x_i, y_i \leq 10^9), the position of the ith minion. The points are given in no particular order, and there cannot be repeated points.

Output

Output four lines each containing two integers. The first integer on each line is the x coordinate of that point, and the second is the y coordinate. The first line should describe the bottom-left corner, the second should describe the top-left corner, the third should describe the top-right corner, and the final should describe the bottom-right corner.

Together these point should describe the minimal (in terms of width and height) axis-aligned rectangle that encloses all the minions' positions

Example

Input 1
4
1 5
2 2
5 4
-2 -1
Output 1
-2 -1
-2 5
5 5
5 -1

Input 2
2
1 -2
1 5
Output 2
1 -2
1 5
1 5
1 -2

The rectangle may have zero width or height - being on the boundary counts as being enclosed so this is a valid solution.

Input 3
1
1 1
Output 3
1 1
1 1
1 1
1 1

This 0-width and 0-height rectangle does enclose the point, so it is the optimal output.

Input 4
4
2 0
0 2
-2 0
0 -2
Output 4
-2 -2
-2 2
2 2
2 -2


Comments

There are no comments at the moment.