eolymp
bolt
Try our new interface for solving problems
Problems

Floor Painting

Floor Painting

The museum of Bizarre Argentinean Pocket Calculators (BAPC) has found a great painter to make a nice floor painting for in the museum. All walls in the museum are straight, and any two adjacent walls meet at a right angle. All non-adjacent walls are pairwise disjoint. Furthermore, the room in which the painting is supposed to come has no pillars. Hence, it is a rectilinear simple polygon.

The design for the painting is square. The museum wants the painting to be as large as possible. Furthermore, it should be placed such that the edges of the square are parallel to the walls. Find the maximum possible width for the painting.

prb8329.gif

Input

On the first line one positive number: the number of test cases, at most 100. After that per test case:

  • one line with a single integer n (4n1 000): the number of corners in the room.
  • n lines, each with two space-separated integers x and y (0x, y100 000): the coordinates of each corner of the room.

The corners are given in clockwise order.

Output

For each test case print one line with a single integer: the maximum width of a square painting that fits on the floor of the museum.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3
6
0 8
5 8
5 4
8 4
8 0
0 0
4
0 4
4 4
4 0
0 0
14
4 8
12 8
12 6
14 6
14 8
16 8
16 3
8 3
8 0
0 0
0 6
3 6
3 7
4 7
Output example #1
5
4
6
Source 2014 Benelux Algorithm Programming Contest (BAPC), Preliminaries, Problem C