import java.io.*;
import java.util.*;

public class saferoute_bm_wrongang {
	FastScanner in;
	PrintWriter out;

	// 22:03
	// 22:19

	final double eps = 1e-9;

	class Point implements Comparable<Point> {
		double x, y;
		ArrayList<Edge> outEdges;

		public Point(double x, double y) {
			super();
			this.x = x;
			this.y = y;
			outEdges = new ArrayList<>();
		}

		boolean same(Point an) {
			return Math.abs(an.x - x) + Math.abs(an.y - y) <= eps;
		}

		@Override
		public int compareTo(Point o) {
			if (Math.abs(o.x - x) < eps)
				return Double.compare(y, o.y);
			return Double.compare(x, o.x);
		}
	}

	class Line {
		double A, B, C;
		ArrayList<Point> pts;

		Line(Point a, Point b) {
			A = b.y - a.y;
			B = a.x - b.x;
			C = -(A * a.x + B * a.y);
			pts = new ArrayList<>();
		}

		boolean onLine(Point p) {
			return Math.abs(A * p.x + B * p.y + C) <= eps;
		}
	}

	Point intersect(Line l1, Line l2) {
		double zn = l1.A * l2.B - l1.B * l2.A;
		if (Math.abs(zn) < eps)
			return null;
		double x = (l2.C * l1.B - l1.C * l2.B);
		double y = (l1.C * l2.A - l2.C * l1.A);
		return new Point(x / zn, y / zn);
	}

	boolean contains(ArrayList<Point> pts, Point cur) {
		for (Point already : pts) {
			if (cur.same(already)) {
				return true;
			}
		}
		return false;
	}

	class Edge implements Comparable<Edge> {
		Point from, to;
		double dx, dy;
		double angle;
		double cost;
		boolean used;

		public Edge(Point from, Point to) {
			super();
			this.from = from;
			this.to = to;
			this.dx = to.x - from.x;
			this.dy = to.y - from.y;
			angle = Math.atan2(dy, dx);
			this.cost = Double.MAX_VALUE;
		}

		@Override
		public int compareTo(Edge o) {
			return Double.compare(cost, o.cost);
		}

	}

	void solve() {
		int n = in.nextInt();
		Line[] l = new Line[n];
		for (int i = 0; i < n; i++) {
			l[i] = new Line(new Point(in.nextInt(), in.nextInt()), new Point(
					in.nextInt(), in.nextInt()));
		}
		Point start = new Point(in.nextInt(), in.nextInt());
		Point end = new Point(in.nextInt(), in.nextInt());

		ArrayList<Point> allPoints = new ArrayList<>();
		allPoints.add(start);
		allPoints.add(end);
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				Point inter = intersect(l[i], l[j]);
				if (inter != null) {
					if (!contains(allPoints, inter)) {
						allPoints.add(inter);
					}
				}
			}
		}
		Collections.sort(allPoints);
		for (int i = 0; i < n; i++) {
			for (Point p : allPoints) {
				if (l[i].onLine(p)) {
					l[i].pts.add(p);
				}
			}
			for (int j = 0; j < l[i].pts.size() - 1; j++) {
				Point from = l[i].pts.get(j), to = l[i].pts.get(j + 1);
				Edge e = new Edge(from, to);
				Edge rev = new Edge(to, from);
				from.outEdges.add(e);
				to.outEdges.add(rev);
			}
		}
		PriorityQueue<Edge> pq = new PriorityQueue<>();
		for (Edge e : start.outEdges) {
			e.cost = 0;
			pq.add(e);
		}
		double answer = Double.MAX_VALUE;
		while (pq.size() > 0) {
			Edge e = pq.poll();
			if (e.used) {
				continue;
			}
			e.used = true;
			if (e.to == end) {
				answer = e.cost;
				break;
			}
			for (Edge outEdge : e.to.outEdges) {
				double newCost = norm(Math.abs(e.angle - outEdge.angle))
						+ e.cost;
				if (outEdge.cost > newCost) {
					outEdge.cost = newCost;
					pq.add(outEdge);
				}
			}
		}
		if (answer == Double.MAX_VALUE) {
			out.println(-1);
			return;
		}
		out.printf(Locale.US, "%.17f\n", answer / Math.PI * 180);
	}

	double norm(double angle) {
		while (angle < -eps) {
			angle += Math.PI * 2;
		}
		while (angle > Math.PI * 2 - eps) {
			angle -= Math.PI * 2;
		}
		return angle;
	}

	void run() {
		try {
			in = new FastScanner(new File("saferoute.in"));
			out = new PrintWriter(new File("saferoute.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new saferoute_bm_wrongang().run();
	}
}