Two villages are separated by a river that flows from the north to the south. The villagers want to build a bridge across the river to make it easier to move across the villages.

The river banks can be assumed to be vertical straight lines x = a and x = b (0 < a < b).

The west village lies in a steppe at point O = (0, 0). There are n pathways leading from the village to the river, they end at points A_{i} = (a, y_{i}). The villagers there are plain and simple, so their pathways are straight segments as well.

The east village has reserved and cunning people. Their village is in the forest on the east bank of the river, but its exact position is not clear. There are m twisted paths leading from this village to the river and ending at points B_{i} = (b, y'_{i}). The lengths of all these paths are known, the length of the path that leads from the eastern village to point B_{i}, equals l_{i}.

The villagers want to choose exactly one point on the left bank of river A_{i}, exactly one point on the right bank B_{j} and connect them by a straight-line bridge so as to make the total distance between the villages (the sum of |OA_{i}| + |A_{i}B_{j}| + l_{j}, where |XY| is the Euclidean distance between points X and Y) were minimum. The Euclidean distance between points (x_1, y_1) and (x_2, y_2) equals $\sqrt{(x_{1} - x_{2})^{2} +(y_{1} - y_{2})^{2}}$.

Help them and find the required pair of points.


-----Input-----

The first line contains integers n, m, a, b (1 ≤ n, m ≤ 10^5, 0 < a < b < 10^6). 

The second line contains n integers in the ascending order: the i-th integer determines the coordinate of point A_{i} and equals y_{i} (|y_{i}| ≤ 10^6). 

The third line contains m integers in the ascending order: the i-th integer determines the coordinate of point B_{i} and equals y'_{i} (|y'_{i}| ≤ 10^6). 

The fourth line contains m more integers: the i-th of them determines the length of the path that connects the eastern village and point B_{i}, and equals l_{i} (1 ≤ l_{i} ≤ 10^6).

It is guaranteed, that there is such a point C with abscissa at least b, that |B_{i}C| ≤ l_{i} for all i (1 ≤ i ≤ m). It is guaranteed that no two points A_{i} coincide. It is guaranteed that no two points B_{i} coincide.


-----Output-----

Print two integers — the numbers of points on the left (west) and right (east) banks, respectively, between which you need to build a bridge. You can assume that the points on the west bank are numbered from 1 to n, in the order in which they are given in the input. Similarly, the points on the east bank are numbered from 1 to m in the order in which they are given in the input.

If there are multiple solutions, print any of them. The solution will be accepted if the final length of the path will differ from the answer of the jury by no more than 10^{ - 6} in absolute or relative value.


-----Examples-----
Input
3 2 3 5
-2 -1 4
-1 2
7 3

Output
2 2

Difficulty: HARD
Tags: Geometry

Sorting

Amortized analysis
Skill types: Sorting

Amortized analysis

Starter code:

Solutions:
import sys
from itertools import *
from math import *

def solve():
	(n, m, leftbank, rightbank) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = list(map(int, input().split()))
	smallx = leftbank
	smallxsquared = smallx * smallx
	rightbankminusleftbanksquared = (rightbank - leftbank) * (rightbank - leftbank)
	(leftbest, rightbest, distbest) = (-1, -1, 100000000)
	for (i, bcord, length) in zip(count(), b, l):
		wanty = bcord * smallx / rightbank
		(ll, rr) = (0, n - 1)
		while ll < rr:
			mm = (ll + rr + 1) // 2
			if a[mm] > wanty:
				rr = mm - 1
			else:
				ll = mm
		for pos in range(ll, ll + 2):
			if pos < n:
				temp = a[pos]
				first = sqrt(smallxsquared + temp * temp)
				temp = bcord - a[pos]
				second = sqrt(rightbankminusleftbanksquared + temp * temp)
				totaldist = first + second + length
				if totaldist < distbest:
					distbest = totaldist
					leftbest = pos
					rightbest = i
	print(leftbest + 1, rightbest + 1)
if sys.hexversion == 50594544:
	sys.stdin = open('test.txt')
solve()


from math import sqrt, fabs

def dist(x1, y1, x2, y2):
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2))

def calcOptimumRightPoint(startX, startY):
	l = float('inf')
	idx = -1
	for i in range(len(B)):
		d = dist(startX, startY, b, B[i]) + L[i]
		if d <= l:
			l = d
			idx = i
	return idx
(n, m, a, b) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
optimumRightPoint = calcOptimumRightPoint(0, 0)
intersectLeft = a * B[optimumRightPoint] / b
l = float('inf')
optimumLeftPoint = -1
for i in range(len(A)):
	if fabs(intersectLeft - A[i]) < l:
		l = fabs(intersectLeft - A[i])
		optimumLeftPoint = i
optimumRightPoint = calcOptimumRightPoint(a, A[optimumLeftPoint])
print(optimumLeftPoint + 1, optimumRightPoint + 1)


import sys

def pro():
	return sys.stdin.readline().strip()

def rop():
	return map(int, pro().split())

def main():
	s = list(rop())
	a = list(rop())
	q = list(rop())
	o = list(rop())
	p = -1
	t = (1e+100, -1, -1)
	for i in range(s[1]):
		while not ((p == -1 or s[2] * q[i] - s[3] * a[p] >= 0) and (p + 1 == s[0] or s[2] * q[i] - s[3] * a[p + 1] < 0)):
			p += 1
		if p != -1:
			t = min(t, (o[i] + (s[2] ** 2 + a[p] ** 2) ** 0.5 + ((s[3] - s[2]) ** 2 + (q[i] - a[p]) ** 2) ** 0.5, p, i))
		if p + 1 != s[0]:
			t = min(t, (o[i] + (s[2] ** 2 + a[p + 1] ** 2) ** 0.5 + ((s[3] - s[2]) ** 2 + (q[i] - a[p + 1]) ** 2) ** 0.5, p + 1, i))
	print(t[1] + 1, t[2] + 1)
main()


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
(n, m, a, b) = mints()
A = list(mints())
B = list(mints())
l = list(mints())
j = -1
r = (1e+100, -1, -1)
for i in range(m):
	while not ((j == -1 or a * B[i] - b * A[j] >= 0) and (j + 1 == n or a * B[i] - b * A[j + 1] < 0)):
		j += 1
	if j != -1:
		r = min(r, (l[i] + sqrt(a * a + A[j] * A[j]) + sqrt((b - a) ** 2 + (B[i] - A[j]) ** 2), j, i))
	if j + 1 != n:
		r = min(r, (l[i] + sqrt(a * a + A[j + 1] * A[j + 1]) + sqrt((b - a) ** 2 + (B[i] - A[j + 1]) ** 2), j + 1, i))
print(r[1] + 1, r[2] + 1)


__author__ = 'Michael Ilyin'
import math
debug = False

def dist(x1, y1, x2, y2):
	return math.sqrt(math.pow(math.fabs(x1 - x2), 2) + math.pow(math.fabs(y1 - y2), 2))

def get_y(x1, y1, x2, y2, x):
	return (x - x1) * (y2 - y1) / (x2 - x1) + y1
if debug:
	with open('input.txt', 'r') as inp:
		firstLine = inp.readline()
		secondLine = inp.readline()
		thirdLine = inp.readline()
		fourthLine = inp.readline()
else:
	firstLine = input()
	secondLine = input()
	thirdLine = input()
	fourthLine = input()
first = firstLine.split()
n = float(first[0])
m = float(first[1])
a = float(first[2])
b = float(first[3])
A = [float(x) for x in secondLine.split()]
B = [float(x) for x in thirdLine.split()]
L = [float(x) for x in fourthLine.split()]
if debug:
	print(A)
	print(B)
	print(L)
optimalLen = float('inf')
optimalBIdx = -1
for (i, bi) in enumerate(B):
	d = dist(0, 0, b, bi) + L[i]
	if d <= optimalLen:
		optimalLen = d
		optimalBIdx = i
if debug:
	print(optimalBIdx + 1, optimalLen)
intersectY = get_y(0, 0, b, B[optimalBIdx], a)
if debug:
	print(intersectY)
pointDist = float('inf')
optimalAIdx = -1
for (i, ai) in enumerate(A):
	d = dist(a, ai, a, intersectY)
	if d < pointDist:
		pointDist = d
		optimalAIdx = i
if debug:
	print(optimalAIdx + 1, pointDist)
optimalLen = float('inf')
optimalBIdx = -1
for (i, bi) in enumerate(B):
	d = dist(a, A[optimalAIdx], b, bi) + L[i]
	if d <= optimalLen:
		optimalLen = d
		optimalBIdx = i
print(optimalAIdx + 1, optimalBIdx + 1)