// Arup Guha
// 10/5/2024
// Solution to 2024 NAQ Problem B: Bikes and Barricades

import java.util.*;

public class bikesandbarricades {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		
		double res = -1;
		
		for (int i=0; i<n; i++) {
		
			double x1 = stdin.nextDouble();
			double y1 = stdin.nextDouble();
			double x2 = stdin.nextDouble();
			double y2 = stdin.nextDouble();
			
			if (x1 < 0 && x2 < 0) continue;
			if (x1 > 0 && x2 > 0) continue;
			
			// Get change vector.
			double dx = x2-x1;
			double dy = y2-y1;
		
			// Here is the y intersection for the case where x1 < 0
			double y = 0;
			if (x1 < 0)
				y = y1 + dy*Math.abs(x1)/dx;
			
			// and x2 < 0.
			else
				y = y2 + dy*Math.abs(x2)/dx;
			
			// Update if necessary.
			if (y > 0 && (res == -1 || y < res)) res = y;
		}
		
		System.out.println(res);
	}
}