Intersection of segments#714

Intersection of segments

2 seconds
256 megabytes
Medium

Two segments and [C, D] are given on the plane by the coordinates of their endpoints: points , , , and with coordinates (X_A, Y_A), (X_B, Y_B), (X_C, Y_C), (X_D, Y_D).

Determine the intersection of these segments and output:

Input

The input consists of four lines, each containing two integers, representing the coordinates of points , , , and . The absolute value of each integer does not exceed . The segments may be degenerate.

Output

Numeric values in the output should be rounded to digits after the decimal point.

Examples

Example 1

Loading
Loading