Sum of Vectors

Time limit0.5sMemory limit512 MB

Summary
Choose two of N vectors, each optionally sign-flipped per coordinate, to minimize the norm of their sum and output the pair with the chosen flips.
Level

Hard8 of 10

Topics
Sorting, Geometry, Brute force, Math
Solved
No attempts yet

Problem

There are NN two-dimensional vectors. You can apply an operation that multiplies each coordinate by −1-1. For example, if v=(x,y)v = (x, y), you can transform it into one of the following four forms.

  • 1: (x,y)(x, y)
  • 2: (−x,y)(-x, y)
  • 3: (x,−y)(x, -y)
  • 4: (−x,−y)(-x, -y)

Among the NN vectors, choose two vectors viv_i and vjv_j and write a program that finds the minimum value of ∣vi+vj∣|v_i + v_j|. Each of the two vectors may be transformed into one of the four forms above by applying the operation.

Input

The first line gives the number of vectors NN (2≤N≤100,0002 \le N \le 100{,}000). Each of the next NN lines gives the coordinates xix_i, yiy_i of the ii-th vector viv_i (−10,000≤x,y≤10,000-10{,}000 \le x, y \le 10{,}000), one vector per line.

Output

On the first line, print four integers ii, k1k_1, jj, k2k_2 separated by spaces. ii and jj are the indices of the chosen vectors, and k1k_1, k2k_2 are the numbers of the operations applied. If several answers attain the minimum, print any one of them.

Hint

The sum of two vectors v=(xv,yv)v = (x_v, y_v) and u=(xu,yu)u = (x_u, y_u) is s=v+u=(xv+xu,yv+yu)s = v + u = (x_v + x_u, y_v + y_u).

For a vector v=(x,y)v = (x, y), ∣v∣|v| is x2+y2\sqrt{x^2 + y^2}.

Examples2

  1. Example 1

    Input
    5
    -7 -3
    9 0
    -8 6
    7 -8
    4 -5
    
    Expected output
    3 2 4 2
    
  2. Example 2

    Input
    5
    3 2
    -4 7
    -6 0
    -8 4
    5 1
    
    Expected output
    3 4 5 4