Under construction

Still being built. Things may change

Cookies

Time limit2sMemory limit1024 MB

Summary
Split a given convex quadrilateral into exactly three trapezoids with nonzero area that do not overlap and together cover the whole quadrilateral.
Level

Medium6 of 10

Topics
Geometry, Implementation
Solved
No attempts yet

Statement

Young Luke is a very gifted Jedi. Besides his remarkable talent for getting into trouble, he can move objects without touching them. Unfortunately, telekinesis lessons start only in the fifth grade of the Jedi school, so he found an old book in his father's library called Telekinesis for the Little Ones.

The first exercise in the book was moving a cookie through space by thought. Luke had a whole pack of square cookies at hand, so he decided to test his abilities. According to the book, to move a square cookie with telekinesis, you must first break it into exactly three trapezoid pieces, then concentrate and use the force.

Help Luke break the cookie so that exactly three pieces are formed, each of which has the shape of a trapezoid (a convex quadrilateral with two parallel sides).

Input

The input file contains the cookie, a quadrilateral. Four lines give the coordinates of its vertices in counterclockwise order. The i-th line contains two numbers x_i and y_i, the coordinates of the i-th vertex.

No three points lie on the same line.

All coordinates have absolute value at most 1000010000.

Output

Print three quadrilaterals to the output file. Each one is a trapezoid described by four lines, and each line contains two real numbers x_i and y_i, the coordinates of the i-th vertex of the trapezoid, in counterclockwise order. Each trapezoid must have nonzero area. Print an empty line after each trapezoid description.

All points of each trapezoid must lie inside or on the boundary of the original quadrilateral. The trapezoids must not overlap with nonzero area, and every point of the original quadrilateral must be covered by at least one of the three trapezoids.

If several solutions exist, print any of them. When the answer is checked, two areas are considered equal if their relative or absolute difference is at most 10−510^{-5}, a point lies on a line if its distance to the line is at most 10−810^{-8}, and two lines are parallel if the sine of the angle between them is at most 10−710^{-7}.

Hint

Note that the resulting trapezoids may have both pairs of opposite sides parallel to each other. This case is covered by the first example.

The second example is shown in the following figure.

Examples2

  1. Example 1

    Input
    0 0
    2 0
    2 2
    0 2
    
    Expected output
    0 0
    1 0
    1 1
    0 1
    
    1 0
    2 0
    2 1
    1 1
    
    0 1
    2 1
    2 2
    0 2
    
  2. Example 2

    Input
    0 0
    20 20
    0 10
    -20 20
    
    Expected output
    0 0
    11 11
    3 7
    -2 2
    
    3 7
    11 11
    20 20
    0 10
    
    -2 2
    3 7
    0 10
    -20 20