Under construction

Still being built. Things may change

Building Marble Tracks

Time limit4sMemory limit2048 MB

Summary
Given n non-vertical segments in priority order, scan them and keep each one that crosses none of the already kept segments, then print the kept indices.
Level

Hard8 of 10

Topics
Geometry, Greedy, Segment tree
Solved
No attempts yet

Problem

Jonathan wants you to attach some marble tracks to the wall so he can play with them. Each track is a straight piece of plastic with a small indent on one side for the marble to roll in. After you ask how he wants them attached, he spends 15 minutes with crayons drawing a blueprint. You tell him that two tracks cannot be built if they intersect at an inner point. Jonathan thinks about this for a moment, then changes the blueprint. Instead of fixing the conflicts, he numbers all tracks from 1 (his most favorite) to nn (his least favorite).

The first sample (original blueprint).

You need to decide which tracks to build. You go through the tracks from his most favorite to his least favorite, and you build a track only if it does not intersect any track you have already attached to the wall.

Input

The first line contains one integer nn (1≤n≤6⋅1041 \leq n \leq 6 \cdot 10^4), the number of marble tracks in the blueprint.

Each of the following nn lines contains four integers x1x_1, y1y_1, x2x_2, y2y_2 (−105≤x1,y1,x2,y2≤105-10^5 \leq x_1, y_1, x_2, y_2 \leq 10^5, x1≠x2x_1 \neq x_2). They describe a track from (x1,y1)(x_1, y_1) to (x2,y2)(x_2, y_2) in the blueprint.

The tracks are given from most to least favorite. Two different tracks intersect in at most one point.

Output

Print one integer kk on the first line, the number of tracks to build. On the next line, print the kk indices of those tracks in increasing order.

Hint

As you might have noticed, the input format specifies x1≠x2x_1 \neq x_2 for each track. This is because a marble cannot roll down a vertical track.

Examples3

  1. Example 1

    Input
    6
    3 2 5 4
    0 4 4 0
    2 1 6 1
    5 4 7 2
    0 3 5 3
    4 2 6 0
    
    Expected output
    4
    1 2 4 6
    
  2. Example 2

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

    Input
    10
    -30428 50667 -18028 82591
    -19828 85240 -16439 54314
    -16439 54314 -13911 33099
    -18028 82591 -13739 13271
    -13911 33099 -11978 -46941
    -13739 13271 14783 13050
    -11978 -46941 35511 -79125
    35511 -79125 35524 -89845
    35524 -89845 67295 -41898
    14783 13050 72720 -67171
    
    Expected output
    6
    1 3 5 7 8 9