Cow Steeplechase II#10320

Cow Steeplechase II

1 second
128 megabytes
Very hard (≈2050)

In the past, Farmer John has come up with a number of innovative ideas for new cow sports, among them Cow Steeplechase, in which herds of cows race around a course and jump over hurdles. His earlier efforts to build interest in this sport have met with mixed results, so he is planning to build an even larger Cow Steeplechase course on his farm to attract more publicity to the sport.

Farmer John's new course is carefully planned around hurdles, conveniently numbered from to . Each hurdle is represented as a line segment on a 2D map of the course. These segments must not intersect each other in any way, not even at their endpoints.

Unfortunately, Farmer John was not paying attention when drawing the map, and he now notices that some segments intersect. However, he also notices that removing just one segment restores the map to its intended state, in which no two segments intersect (not even at endpoints).

Determine a segment that Farmer John can remove from his plan so that no two of the remaining segments intersect. If several segments can be removed in this way, print the one that appears earliest in the input.

Input

The first line contains an integer n~(2 \le n \le 10^5). Each of the next lines describes one segment with four integers x_1, y_1, x_2, y_2~(0 \le x_1, y_1, x_2, y_2 \le 10^9), which means that the segment has endpoints (x_1, y_1) and (x_2, y_2). All endpoints are pairwise distinct.

Output

Print the smallest index of a segment whose removal leaves no two of the remaining segments intersecting.

Examples

Example 1

Loading
Loading

Note

Be careful about integer overflow: the coordinates of the endpoints can be as large as 10^9.