Under construction

Still being built. Things may change

Expansion Work

Time limit3sMemory limit1024 MB

Summary
After each new sign is added, print the perimeter and area of the smallest convex polygon that contains all signs placed so far.
Level

Medium7 of 10

Topics
Geometry, Binary search, Implementation
Solved
No attempts yet

Problem

Kiwi is looking for new land to grow eggplants. Kiwi's friend Yutil suggested placing NN signs on flat ground and starting the farm there. However, Kiwi can only farm inside the convex polygon with the smallest area that contains all the given signs.

Kiwi started farming. Yutil came to check on the farm, was moved to see Kiwi working hard on the eggplants, and said: "I will place one new sign each day for the next QQ days. Your new farmland is the convex polygon with the smallest area that contains all existing signs and the new sign. Congratulations! I also have to report the new farmland to the community center, so could you tell me the perimeter and area of the new farmland each day?"

Input

The first line contains the number of signs NN (N=3N = 3).

Each of the next NN lines contains the position of a sign, xix_i and yiy_i, separated by a space (0≤xi,yi≤1090 \le x_i, y_i \le 10^{9}).

The next line contains the number of new signs QQ (1≤Q≤300 0001 \le Q \le 300\,000).

Each of the next QQ lines contains the position of a new sign, aia_i and bib_i, separated by a space (0≤ai,bi≤1090 \le a_i, b_i \le 10^{9}).

No two signs are at the same position, and the first three signs are not on a single line.

Output

Print QQ lines, each with the perimeter and area of the new farmland. An absolute or relative error of up to 10−610^{-6} is allowed.

Examples1

  1. Example 1

    Input
    3
    1 5
    4 8
    6 4
    6
    3 3
    9 2
    2 6
    3 11
    8 8
    11 9
    
    Expected output
    14.705481427 13.0
    20.964080018 21.5
    20.964080018 21.5
    26.052398802 32.0
    27.149459401 45.5
    30.762066116 62.0