This page is still under construction.

Parts of this page are still being built. What you see may change.

Two Rectangles

Time limit1sMemory limit128 MB

Summary
Cover all given points with two non-overlapping axis-aligned rectangles and minimize the larger area.
Level

Medium7 of 10

Topics
Geometry, Sorting
Solved
No attempts yet

Problem

You are given NN points in the plane. Cover all of them with two axis-parallel rectangles, and make the area of the larger rectangle as small as you can.

The two rectangles must not overlap. Touching along an edge or at a corner is allowed. The two rectangles do not have to be the same shape or the same size. A rectangle may have width or height 00, and then its area is 00.

Every point has to lie inside one of the two rectangles or on its boundary.

The arrangement in the picture is not an answer, because the larger rectangle can still be shrunk. The 2020 points drawn there are the second block of the first test case below.

Input

Input arrives on standard input. The first line holds the number of test cases TT (1≤T≤201 \le T \le 20).

Each test case starts with a line holding the number of points NN (1≤N≤100001 \le N \le 10000). The next NN lines each hold the coordinates of one point as two integers. Every coordinate is an integer between −30000-30000 and 3000030000. The same point may be given more than once.

Output

Write to standard output. For each test case, print on its own line the area of the larger of the two rectangles, minimized.

Examples1

  1. Example 1

    Input
    2
    2
    10 10
    20 20
    20
    0 4
    1 1
    1 6
    2 0
    2 2
    2 3
    2 5
    3 4
    3 5
    4 2
    4 3
    5 0
    5 4
    6 2
    6 5
    7 0
    8 1
    8 4
    10 2
    10 4
    
    Expected output
    0
    25