Igor the analyst fell asleep on the work and had a strange dream. In the dream his desk was crowded with computer mice, so he bought a mousetrap to catch them.

The desk can be considered as an infinite plane, then the mousetrap is a rectangle which sides are parallel to the axes, and which opposite sides are located in points (x1, y1) and (x2, y2).

Igor wants to catch all mice. Igor has analysed their behavior and discovered that each mouse is moving along a straight line with constant speed, the speed of the i-th mouse is equal to (vix, viy), that means that the x coordinate of the mouse increases by vix units per second, while the y coordinates increases by viy units. The mousetrap is open initially so that the mice are able to move freely on the desk. Igor can close the mousetrap at any moment catching all the mice that are strictly inside the mousetrap.

Igor works a lot, so he is busy in the dream as well, and he asks you to write a program that by given mousetrap's coordinates, the initial coordinates of the mice and their speeds determines the earliest time moment in which he is able to catch all the mice. Please note that Igor can close the mousetrap only once.

Input

The first line contains single integer n (1 ≤ n ≤ 100 000) — the number of computer mice on the desk.

The second line contains four integers x1, y1, x2 and y2 (0 ≤ x1 ≤ x2 ≤ 100 000), (0 ≤ y1 ≤ y2 ≤ 100 000) — the coordinates of the opposite corners of the mousetrap.

The next n lines contain the information about mice.

The i-th of these lines contains four integers rix, riy, vix and viy, (0 ≤ rix, riy ≤ 100 000,  - 100 000 ≤ vix, viy ≤ 100 000), where (rix, riy) is the initial position of the mouse, and (vix, viy) is its speed.

Output

In the only line print minimum possible non-negative number t such that if Igor closes the mousetrap at t seconds from the beginning, then all the mice are strictly inside the mousetrap. If there is no such t, print -1.

Your answer is considered correct if its absolute or relative error doesn't exceed 10 - 6. 

Formally, let your answer be a, and the jury's answer be b. Your answer is considered correct if <image>.

Examples

Input

4
7 7 9 8
3 5 7 5
7 5 2 4
3 3 7 8
6 6 3 2


Output

0.57142857142857139685


Input

4
7 7 9 8
0 3 -5 4
5 0 5 4
9 9 -1 -6
10 5 -7 -10


Output

-1

Note

Here is a picture of the first sample

Points A, B, C, D - start mice positions, segments are their paths.

<image>

Then, at first time when all mice will be in rectangle it will be looks like this:

<image>

Here is a picture of the second sample

<image>

Points A, D, B will never enter rectangle.

Source: codeforces | Difficulty: HARD
Tags: Mathematics

Geometry

Sorting

Implementation


Solutions:
import math
n = int(input())
(x1, y1, x2, y2) = map(int, input().split())
t1 = 0
t2 = math.inf
yes = True
for i in range(n):
	(x, y, vx, vy) = map(int, input().split())
	if vx == 0:
		if x <= x1 or x >= x2:
			yes = False
			break
	else:
		tt1 = (x1 - x) / vx
		tt2 = (x2 - x) / vx
		(tt1, tt2) = (min(tt1, tt2), max(tt1, tt2))
		t1 = max(t1, tt1)
		t2 = min(t2, tt2)
	if vy == 0:
		if y <= y1 or y >= y2:
			yes = False
			break
	else:
		tt1 = (y1 - y) / vy
		tt2 = (y2 - y) / vy
		(tt1, tt2) = (min(tt1, tt2), max(tt1, tt2))
		t1 = max(t1, tt1)
		t2 = min(t2, tt2)
if yes and t1 < t2:
	print(t1)
else:
	print(-1)


import sys
lines = sys.stdin.read().split('\n')[1:][:-1]
line_1 = lines.pop(0)
(x_1, y_1, x_2, y_2) = map(int, line_1.split())

def terminate_with_fail():
	print('-1', end='')
	sys.exit()

def move(x, y, dx, dy, t):
	return (x + t * dx, y + t * dy)

def enter_line(k, dk, k_1, k_2):
	if k_1 < k < k_2:
		return 0
	elif dk == 0:
		terminate_with_fail()
	move_time = min((k_1 - k) / dk, (k_2 - k) / dk)
	if move_time < 0 or k_1 == k_2:
		terminate_with_fail()
	return move_time

def exit_line(k, dk, k_1, k_2):
	if dk == 0:
		return float('inf')
	else:
		return max((k_1 - k) / dk, (k_2 - k) / dk)
earliest = 0
latest = float('inf')
for line in lines:
	(x, y, dx, dy) = map(int, line.split())
	move_time_x = enter_line(x, dx, x_1, x_2)
	(x, y) = move(x, y, dx, dy, move_time_x)
	move_time_y = enter_line(y, dy, y_1, y_2)
	(x, y) = move(x, y, dx, dy, move_time_y)
	start_time = move_time_x + move_time_y
	move_time_x_end = exit_line(x, dx, x_1, x_2)
	move_time_y_end = exit_line(y, dy, y_1, y_2)
	end_time = start_time + min(move_time_x_end, move_time_y_end)
	earliest = max(earliest, start_time)
	latest = min(latest, end_time)
if earliest >= latest:
	terminate_with_fail()
print(str(earliest), end='')


def comp(x, v, l, r):
	if x < l and v <= 0:
		return [-1, -10]
	if x > r and v >= 0:
		return [-1, -10]
	if x >= l and x <= r:
		if v == 0:
			if x == l or x == r:
				return [-1, -10]
			else:
				return [0, 10 ** 18]
		if v > 0:
			s = 0
			e = (r - x) / v
			return [s, e]
		if v < 0:
			s = 0
			e = (x - l) / -v
			return [s, e]
	if x < l:
		s = (l - x) / v
		e = (r - x) / v
		return [s, e]
	if x > r:
		s = (x - r) / -v
		e = (x - l) / -v
		return [s, e]
	print(x, v, l, r)
n = int(input())
(x1, y1, x2, y2) = map(int, input().split())
lo = 1e-09
hi = 10 ** 18
for i in range(n):
	(x, y, vx, vy) = map(int, input().split())
	l1 = comp(x, vx, x1, x2)
	l2 = comp(y, vy, y1, y2)
	lo = max(lo, l1[0], l2[0])
	hi = min(hi, l1[1], l2[1])
if lo < hi:
	print(lo)
else:
	print(-1)


n = int(input())
(x1, y1, x2, y2) = [int(x) for x in input().split()]
st = [0]
et = [10000000000.0]
ok = 1
if x1 == x2 or y1 == y2:
	ok = 0
for i in range(n):
	(a, b, u, w) = [int(x) for x in input().split()]
	for (x, v, s, e) in ((a, u, x1, x2), (b, w, y1, y2)):
		if v == 0:
			if not s < x < e:
				ok = 0
		else:
			t1 = (s - x) / v
			t2 = (e - x) / v
			st += [min(t1, t2)]
			et += [max(t1, t2)]
if max(st) < min(et) and min(et) > 0 and ok:
	print(max(max(st), 0))
else:
	print(-1)


import sys
input = sys.stdin.readline
mintime = (0, 1)
maxtime = (10 ** 9, 1)
useless = 0
n = int(input())
(x1, y1, x2, y2) = map(int, input().split())
for _ in range(n):
	(rx, ry, vx, vy) = map(int, input().split())
	if vx == 0:
		if not x1 < rx < x2:
			useless = 1
			break
	else:
		t1 = (x1 - rx, vx)
		t2 = (x2 - rx, vx)
		if vx < 0:
			t1 = (-t1[0], -t1[1])
			t2 = (-t2[0], -t2[1])
		if t1[0] * t2[1] > t1[1] * t2[0]:
			(t1, t2) = (t2, t1)
		if mintime[0] * t1[1] < mintime[1] * t1[0]:
			mintime = t1
		if maxtime[0] * t2[1] > maxtime[1] * t2[0]:
			maxtime = t2
	if vy == 0:
		if not y1 < ry < y2:
			useless = 1
			break
	else:
		t1 = (y1 - ry, vy)
		t2 = (y2 - ry, vy)
		if vy < 0:
			t1 = (-t1[0], -t1[1])
			t2 = (-t2[0], -t2[1])
		if t1[0] * t2[1] > t1[1] * t2[0]:
			(t1, t2) = (t2, t1)
		if mintime[0] * t1[1] < mintime[1] * t1[0]:
			mintime = t1
		if maxtime[0] * t2[1] > maxtime[1] * t2[0]:
			maxtime = t2
if useless or mintime[0] * maxtime[1] >= maxtime[0] * mintime[1]:
	print(-1)
else:
	print(mintime[0] / float(mintime[1]))


from sys import stdin, stdout
from decimal import *

def ri():
	return map(int, stdin.readline().split())

def findt(rx, ry, vx, vy):
	if vx == 0:
		if rx > x1 and rx < x2:
			t1x = Decimal(0)
			t2x = Decimal(10 ** 6)
		else:
			return (2, 1)
	else:
		t1x = Decimal(x1 - rx) / Decimal(vx)
		t2x = Decimal(x2 - rx) / Decimal(vx)
	if vy == 0:
		if ry > y1 and ry < y2:
			t1y = Decimal(0)
			t2y = Decimal(10 ** 6)
		else:
			return (2, 1)
	else:
		t1y = Decimal(y1 - ry) / Decimal(vy)
		t2y = Decimal(y2 - ry) / Decimal(vy)
	if t1x > t2x:
		(t1x, t2x) = (t2x, t1x)
	if t1y > t2y:
		(t1y, t2y) = (t2y, t1y)
	return (max(t1x, t1y), min(t2x, t2y))
n = int(input())
(x1, y1, x2, y2) = ri()
if x1 > x2:
	(x1, x2) = (x2, x1)
if y1 > y2:
	(y1, y2) = (y2, y1)
mintt = 0
maxtt = 10 ** 20
for i in range(n):
	(rx, ry, vx, vy) = ri()
	(mint, maxt) = findt(rx, ry, vx, vy)
	if mint >= maxt:
		print(-1)
		exit()
	if maxt <= 0:
		print(-1)
		exit()
	mintt = max(mint, mintt)
	maxtt = min(maxt, maxtt)
	if mintt >= maxtt:
		print(-1)
		exit()
print(mintt)


rd = lambda : map(int, input().split())
n = int(input())
(x1, y1, x2, y2) = rd()
l = []
r = []
m = []
for i in range(n):
	t = []
	(rx, ry, vx, vy) = rd()
	m.append([rx, ry, vx, vy])
	if x1 <= rx <= x2 and y1 <= ry <= y2:
		t.append(0)
		if vx == 0 and vy == 0:
			t.append(4557430888798830399)
	if vx:
		t1 = (x1 - rx) / vx
		if t1 >= 0:
			if y1 <= ry + t1 * vy <= y2:
				t.append(t1)
		t1 = (x2 - rx) / vx
		if t1 >= 0:
			if y1 <= ry + t1 * vy <= y2:
				t.append(t1)
	if vy:
		t1 = (y1 - ry) / vy
		if t1 >= 0:
			if x1 <= rx + t1 * vx <= x2:
				t.append(t1)
		t1 = (y2 - ry) / vy
		if t1 >= 0:
			if x1 <= rx + t1 * vx <= x2:
				t.append(t1)
	if len(t) < 2:
		print(-1)
		exit()
	t.sort()
	l.append(t[0])
	r.append(t[-1])
l.sort()
r.sort()
if l[-1] > r[0]:
	print(-1)
else:
	p = (l[-1] + r[0]) / 2
	if not all((x1 < rx + p * vx < x2 and y1 < ry + p * vy < y2 for (rx, ry, vx, vy) in m)):
		print(-1)
	else:
		print(l[-1])


n = int(input())
(x1, y1, x2, y2) = map(int, input().split())
(lx, rx, ly, ry) = ([], [], [], [])
pos = True
for i in range(n):
	(x, y, vx, vy) = map(int, input().split())
	if x1 < x < x2:
		lx.append(0)
		if vx == 0:
			rx.append(float('inf'))
		else:
			(gl, gr) = (0, 10 ** 5 + 1)
			while gr - gl > 10 ** (-6):
				m = (gl + gr) / 2
				if x1 < x + m * vx < x2:
					gl = m
				else:
					gr = m
			rx.append(gr)
	elif x >= x2:
		if vx >= 0:
			pos = False
			break
		else:
			lx.append((x2 - x - 10 ** (-6)) / vx)
			rx.append((x1 - x + 10 ** (-6)) / vx)
	elif vx <= 0:
		pos = False
		break
	else:
		lx.append((x1 - x + 10 ** (-6)) / vx)
		rx.append((x2 - x - 10 ** (-6)) / vx)
	if y1 < y < y2:
		ly.append(0)
		if vy == 0:
			ry.append(float('inf'))
		else:
			(gl, gr) = (0, 10 ** 5 + 1)
			while gr - gl > 10 ** (-6):
				m = (gl + gr) / 2
				if y1 < y + m * vy < y2:
					gl = m
				else:
					gr = m
			ry.append(gr)
	elif y >= y2:
		if vy >= 0:
			pos = False
			break
		else:
			ly.append((y2 - y - 10 ** (-6)) / vy)
			ry.append((y1 - y + 10 ** (-6)) / vy)
	elif vy <= 0:
		pos = False
		break
	else:
		ly.append((y1 - y + 10 ** (-6)) / vy)
		ry.append((y2 - y - 10 ** (-6)) / vy)
if not pos:
	print(-1)
else:
	l = max(max(ly), max(lx))
	r = min(min(ry), min(rx))
	if r <= l:
		print(-1)
	else:
		print(l)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy
from itertools import chain, dropwhile, permutations, combinations
from collections import defaultdict, deque

def VI():
	return list(map(int, input().split()))

def I():
	return int(input())

def LIST(n, m=None):
	return [0] * n if m is None else [[0] * m for i in range(n)]

def ELIST(n):
	return [[] for i in range(n)]

def MI(n=None, m=None):
	if n is None:
		(n, m) = VI()
	arr = LIST(n)
	for i in range(n):
		arr[i] = VI()
	return arr

def MS(n=None, m=None):
	if n is None:
		(n, m) = VI()
	arr = LIST(n)
	for i in range(n):
		arr[i] = input()
	return arr

def MIT(n=None, m=None):
	if n is None:
		(n, m) = VI()
	a = MI(n, m)
	arr = LIST(m, n)
	for (i, l) in enumerate(a):
		for (j, x) in enumerate(l):
			arr[j][i] = x
	return arr

def main(info=0):
	n = I()
	(x0, y0, x1, y1) = VI()
	dt = 1e-11

	def inrange(x, x0, x1, inclusive=True):
		if inclusive:
			return x >= x0 and x <= x1
		else:
			return x > x0 and x < x1

	def times(x, y, vx, vy):
		ab = set([])
		if vx == 0 and vy == 0:
			if x > x0 and x < x1 and (y > y0) and (y < y1):
				return (0.0, float('inf'))
		elif vx == 0:
			if x > x0 and x < x1:
				ab = ((y0 - y) / vy, (y1 - y) / vy)
		elif vy == 0:
			if y > y0 and y < y1:
				ab = ((x0 - x) / vx, (x1 - x) / vx)
		else:
			tx0 = (x0 - x) / vx
			tx0y = y + tx0 * vy
			tx1 = (x1 - x) / vx
			tx1y = y + tx1 * vy
			ty0 = (y0 - y) / vy
			ty0x = x + ty0 * vx
			ty1 = (y1 - y) / vy
			ty1x = x + ty1 * vx
			if inrange(tx0y, y0, y1):
				ab.add(tx0)
			if inrange(tx1y, y0, y1):
				ab.add(tx1)
			if inrange(ty0x, x0, x1):
				ab.add(ty0)
			if inrange(ty1x, x0, x1):
				ab.add(ty1)
		if len(ab) == 1:
			ab = []
		return (None, None) if len(ab) == 0 else (min(ab) + dt, max(ab) - dt)
	(tmn, tmx) = (0, float('inf'))
	for i in range(n):
		m = VI()
		(t0, t1) = times(*m)
		if t0 == None:
			tmx = -1
		else:
			tmn = max(t0, tmn)
			tmx = min(t1, tmx)
	if tmn > tmx or tmx == 0:
		print('-1')
		return
	print(tmn)
main()


N = int(input())
(x1, y1, x2, y2) = map(int, input().split())
(maxl, minr) = (0.0, 1e+30)
for i in range(N):
	(rx, ry, vx, vy) = map(int, input().split())
	c = [0.0 for i in range(4)]
	if vx == 0:
		if not (x1 < rx and rx < x2):
			exit(print(-1))
		else:
			c[2] = 0.0
			c[3] = 0.0
	else:
		c[2] = (x1 - rx) / vx
		c[3] = (x2 - rx) / vx
	if vy == 0:
		if not (y1 < ry and ry < y2):
			exit(print(-1))
		else:
			c[0] = 0.0
			c[1] = 0.0
	else:
		c[0] = (y1 - ry) / vy
		c[1] = (y2 - ry) / vy
	for j in range(2):
		xx = rx + c[j] * vx
		if not (x1 <= xx and xx <= x2):
			c[j] = -1.0
	for j in range(2, 4, 1):
		yy = ry + c[j] * vy
		if not (y1 <= yy and yy <= y2):
			c[j] = -1.0
	(ll, rr) = (1e+30, 0.0)
	for j in range(4):
		if c[j] < 0.0:
			continue
		ll = min(ll, c[j])
		rr = max(rr, c[j])
	if x1 < rx and rx < x2 and (y1 < ry) and (ry < y2):
		if vx == 0 and vy == 0:
			continue
		minr = min(minr, rr)
		continue
	if ll == 1e+30 or ll == rr:
		exit(print(-1))
	maxl = max(maxl, ll)
	minr = min(minr, rr)
if minr <= maxl:
	print(-1)
else:
	print('%.8f' % maxl)


def main():
	n = int(input())
	(x1, y1, x2, y2) = map(int, input().split())
	st = [0]
	ed = [100000000000.0]
	if x1 == x2 or y1 == y2:
		print(-1)
		exit()
	for i in range(n):
		(a, b, c, d) = map(int, input().split())
		for (x, v, s, e) in ((a, c, x1, x2), (b, d, y1, y2)):
			if v == 0:
				if not s < x < e:
					print(-1)
					exit()
			else:
				t1 = (s - x) / v
				t2 = (e - x) / v
				st += [min(t1, t2)]
				ed += [max(t1, t2)]
	if max(st) < min(ed) and min(ed) > 0:
		print(max(max(st), 0))
	else:
		print(-1)
	return 0
main()


n = int(input())
(x1, y1, x2, y2) = list(map(int, input().split()))
span = [0, 10000000]
for _ in range(n):
	m = list(map(int, input().split()))
	if m[2] == 0:
		if m[0] <= min(x1, x2) or m[0] >= max(x1, x2):
			span = []
			break
		else:
			x_range = [-100000000, 100000000]
	else:
		x_range = sorted([(x1 - m[0]) / m[2], (x2 - m[0]) / m[2]])
	if m[3] == 0:
		if m[1] <= min(y1, y2) or m[1] >= max(y1, y2):
			span = []
			break
		else:
			y_range = [-100000000, 100000000]
	else:
		y_range = sorted([(y1 - m[1]) / m[3], (y2 - m[1]) / m[3]])
	if x_range[1] < 0 or y_range[1] < 0:
		span = []
		break
	r = [max(x_range[0], y_range[0]), min(x_range[1], y_range[1])]
	span = [max(r[0], span[0]), min(r[1], span[1])]
if len(span) == 0 or span[1] <= span[0]:
	print('-1')
else:
	print('%.8f' % (span[0] + 1e-08))