This page is still under construction.

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

L-Shape Covering

Time limit1sMemory limit128 MB

Summary
Find the minimum area of an axis-aligned L-shape with its top-right corner cut away covering all given points.
Level

Medium7 of 10

Topics
Geometry, Sorting
Solved
No attempts yet

Problem

An L-shape is an axis-aligned rectilinear hexagon with exactly one reflex corner: it is the smallest bounding rectangle of the shape with only its top-right corner cut away. See Figures (a) and (b). The cut may degenerate so that three corners become collinear, as in Figure (b).


Figure (a)


Figure (b)

Given a set of NN points in the plane, an L-shape is said to cover the points if every point lies inside it or on its boundary. Write a program that computes the area of the smallest L-shape covering all of the given points.


Figure (c)


Figure (d)

Figure (c) shows a set of points, and Figure (d) shows the minimum-area L-shape that covers them.

Note that the resulting area may be 00, and the input may contain several points with identical coordinates.

Input

The first line contains the number of test cases TT (1≤T≤201 \le T \le 20).

Each test case begins with a line containing the number of points NN (1≤N≤500001 \le N \le 50000). Each of the next NN lines contains the two integer coordinates of one point separated by a single space; each coordinate is an integer between −30000-30000 and 3000030000.

Output

For each test case, print a single line containing the area of the smallest L-shape that covers the given points.

Examples1

  1. Example 1

    Input
    2
    4
    0 4
    0 0
    1 1
    4 0
    14
    -1 -1
    1 0
    5 0
    7 0
    0 4
    1 2
    1 -2
    3 1
    5 -2
    5 -3
    3 1
    2 0
    0 4
    1 -2
    
    Expected output
    4
    38