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

import static java.lang.Math.*;

public class saferoute_as {
    class Line {
        long a;
        long b;
        long c;

        long x0;
        long y0;

        ArrayList<Point> pts;

        Line(int x1, int y1, int x2, int y2) {
            a = y2 - y1;
            b = x1 - x2;
            c = a * x1 + b * y1;
            x0 = x1;
            y0 = y1;

            pts = new ArrayList<>();
        }

        boolean isParallel(Line other) {
            return a * other.b == b * other.a;
        }

        Point intersect(Line other) {
            long d = a * other.b - b * other.a;
            long xn = c * other.b - b * other.c;
            long yn = a * other.c - c * other.a;
            return new Point(xn, d, yn, d);
        }

        boolean contains(long x, long y) {
            return a * x + b * y == c;
        }
    }

    class Point {
        long xn;
        long xd;
        long yn;
        long yd;

        double pos;

        Point(long xn, long xd, long yn, long yd) {
            long d = gcd(xn, xd);
            xn /= d;
            xd /= d;
            if (xd < 0) {
                xn = -xn;
                xd = -xd;
            }
            d = gcd(yn, yd);
            yn /= d;
            yd /= d;
            if (yd < 0) {
                yn = -yn;
                yd = -yd;
            }
            this.xn = xn;
            this.xd = xd;
            this.yn = yn;
            this.yd = yd;
        }

        @Override
        public boolean equals(Object o) {
            Point point = (Point) o;

            if (xd != point.xd) return false;
            if (xn != point.xn) return false;
            if (yd != point.yd) return false;
            if (yn != point.yn) return false;

            return true;
        }

        @Override
        public int hashCode() {
            int result = (int) (xn ^ (xn >>> 32));
            result = 31 * result + (int) (xd ^ (xd >>> 32));
            result = 31 * result + (int) (yn ^ (yn >>> 32));
            result = 31 * result + (int) (yd ^ (yd >>> 32));
            return result;
        }

        @Override
        public String toString() {
            return "(" + xn + "/" + xd + ", " + yn + "/" + yd + ")";
        }
    }

    long gcd(long x, long y) {
        x = abs(x);
        y = abs(y);
        while (y != 0) {
            long t = y; y = x % y; x = t;
        }
        return x;
    }

    int index = 0;

    class Vertex {
        int line;
        int sp;
        int ft;
        boolean reverse;
        int index;
        boolean mark;

        ArrayList<Edge> edges;

        double cost;

        Vertex(int line, int sp, int ft, boolean reverse) {
            this.line = line;
            this.sp = sp;
            this.ft = ft;
            this.reverse = reverse;
            this.index = saferoute_as.this.index++;

            edges = new ArrayList<>();
            cost = Double.POSITIVE_INFINITY;
        }

        public String toString() {
            return "@" + line + "[" + sp + (reverse ? "==>" : "->") + ft + "]";
        }
    }

    class Edge {
        Vertex to;
        double cost;

        Edge(Vertex to, double cost) {
            this.to = to;
            this.cost = cost;
        }

        public String toString() {
            return to + " " + cost;
        }
    }

    int n;
    Line[] lines;
    ArrayList<Vertex>[] lvx;

    double edgeCost(Vertex v, Vertex w) {
        double vx = -lines[v.line].b;
        double vy = lines[v.line].a;
        if (v.reverse) {
            vx = -vx;
            vy = -vy;
        }
        double wx = -lines[w.line].b;
        double wy = lines[w.line].a;
        if (w.reverse) {
            wx = -wx;
            wy = -wy;
        }
        double vp = vx * wy - vy * wx;
        double sp = vx * wx + vy * wy;
        double ang = atan2(vp, sp);
        return abs(ang);
    }

    ArrayList<Vertex> findVertex(int x, int y) {
        ArrayList<Vertex> res = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (lines[i].contains(x, y)) {
                double px = x - lines[i].x0;
                double py = y - lines[i].y0;
                double ppos = px * (-lines[i].b) + py * lines[i].a;

                for (Vertex v : lvx[i]) {
                    if (v.sp == -1 && v.ft == -1) {
                        res.add(v);
                    } else if (v.sp == -1 && !v.reverse && ppos < lines[i].pts.get(v.ft).pos) {
                        res.add(v);
                    } else if (v.ft == -1 && !v.reverse && lines[i].pts.get(v.sp).pos < ppos) {
                        res.add(v);
                    } else if (v.sp == -1 && v.reverse && lines[i].pts.get(v.ft).pos < ppos) {
                        res.add(v);
                    } else if (v.ft == -1 && v.reverse && ppos < lines[i].pts.get(v.sp).pos) {
                        res.add(v);
                    } else if (v.sp != -1 && v.ft != -1 && !v.reverse && lines[i].pts.get(v.sp).pos < ppos && ppos < lines[i].pts.get(v.ft).pos) {
                        res.add(v);
                    } else if (v.sp != -1 && v.ft != -1 && v.reverse && lines[i].pts.get(v.ft).pos < ppos && ppos < lines[i].pts.get(v.sp).pos) {
                        res.add(v);
                    }
                }
            }
        }
        return res;
    }

    public void run() throws IOException {
        in = new FastScanner(new FileInputStream("saferoute.in"));
        out = new PrintWriter(new File("saferoute.out"));

        n = in.nextInt();
        lines = new Line[n];
        for (int i = 0; i < n; i++) {
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();
            lines[i] = new Line(x1, y1, x2, y2);
        }

        ArrayList<Vertex> vv = new ArrayList<>();
        lvx = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (!lines[i].isParallel(lines[j])) {
                    Point p = lines[i].intersect(lines[j]);
                    boolean exists = false;
                    for (Point q : lines[i].pts) {
                        if (q.equals(p)) {
                            exists = true;
                        }
                    }
                    if (!exists) {
                        lines[i].pts.add(p);
                    }
                }
            }
            double lx = -lines[i].b;
            double ly = lines[i].a;
            for (Point p : lines[i].pts) {
                double px = 1.0 * p.xn / p.xd - lines[i].x0;
                double py = 1.0 * p.yn / p.yd - lines[i].y0;
                p.pos = px * lx + py * ly;
            }
            Collections.sort(lines[i].pts, new Comparator<Point>() {

				@Override
				public int compare(Point o1, Point o2) {
					return Double.compare(o1.pos, o2.pos);
				}
			});
            		
            lvx[i] = new ArrayList<>();
            if (lines[i].pts.size() == 0) {
                Vertex v = new Vertex(i, -1, -1, false);
                vv.add(v);
                lvx[i].add(v);
            } else {
                Vertex v = new Vertex(i, -1, 0, false);
                vv.add(v);
                lvx[i].add(v);
                v = new Vertex(i, 0, -1, true);
                vv.add(v);
                lvx[i].add(v);
                for (int j = 0; j < lines[i].pts.size() - 1; j++) {
                    v = new Vertex(i, j, j + 1, false);
                    vv.add(v);
                    lvx[i].add(v);
                    v = new Vertex(i, j + 1, j, true);
                    vv.add(v);
                    lvx[i].add(v);
                }
                v = new Vertex(i, lines[i].pts.size() - 1, -1, false);
                vv.add(v);
                lvx[i].add(v);
                v = new Vertex(i, -1, lines[i].pts.size() - 1, true);
                vv.add(v);
                lvx[i].add(v);
            }
        }

        for (int i = 0; i < n; i++) {
            for (Vertex v : lvx[i]) {
                if (v.ft != -1) {
                    for (Vertex w : lvx[i]) {
                        if (w.sp == v.ft && w.reverse == v.reverse) {
                            Edge e = new Edge(w, 0);
                            v.edges.add(e);
                        }
                    }
                    Point p = lines[i].pts.get(v.ft);
                    for (int j = 0; j < n; j++) {
                        if (!lines[i].isParallel(lines[j])) {
                            Point q = lines[i].intersect(lines[j]);
                            if (p.equals(q)) {
                                int jind = 0;
                                for (int k = 0; k < lines[j].pts.size(); k++) {
                                    if (lines[j].pts.get(k).equals(q)) {
                                        jind = k;
                                        break;
                                    }
                                }
                                for (Vertex w : lvx[j]) {
                                    if (w.sp == jind) {
                                        Edge e = new Edge(w, edgeCost(v, w));
                                        v.edges.add(e);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        int xs = in.nextInt();
        int ys = in.nextInt();
        int xt = in.nextInt();
        int yt = in.nextInt();

        ArrayList<Vertex> vs = findVertex(xs, ys);
        ArrayList<Vertex> vt = findVertex(xt, yt);
        for (Vertex v : vs) {
            v.cost = 0;
        }

        TreeSet<Vertex> pq = new TreeSet<>(new Comparator<Vertex>() {

			@Override
			public int compare(Vertex o1, Vertex o2) {
				int x = Double.compare(o1.cost, o2.cost);
				if (x == 0)
					return o1.index - o2.index;
				return x;
			}
		});
        
        pq.addAll(vs);
        while (!pq.isEmpty()) {
            Vertex v = pq.pollFirst();
            v.mark = true;
            for (Edge e : v.edges) {
                if (!e.to.mark && e.to.cost > v.cost + e.cost) {
                    pq.remove(e.to);
                    e.to.cost = v.cost + e.cost;
                    pq.add(e.to);
                }
            }
        }

        double ans = Double.POSITIVE_INFINITY;
        for (Vertex v : vt) {
            if (v.mark && v.cost < ans) {
                ans = v.cost;
            }
        }

        if (ans == Double.POSITIVE_INFINITY) {
            out.println(-1);
        } else {
            out.println(ans * 180 / PI);
        }


        out.close();
    }

    FastScanner in;
    PrintWriter out;

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

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream in) throws IOException {
            br = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            try {
                while (st == null || !st.hasMoreTokens()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (IOException e) {
                System.err.println(e);
                System.exit(1);
            }
            return st.nextToken();
        }

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

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