#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;
const double PI = acos(-1.0);

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
    double length() const{
        return sqrt(y * y + x * x);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
    double dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cosθ
    }
    double cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sinθ
    }
};

double segmentPointDist(const Point& a1, const Point& a2, const Point& p)
{
    if((a2-a1).dot(p-a1) < 0)
        return a1.dist(p);
    else if((a1-a2).dot(p-a2) < 0)
        return a2.dist(p);
    else
        return abs((a2-a1).cross(p-a1)) / a1.dist(a2);
}

bool segmentsIntersection(const Point& a1, const Point& a2, const Point& b1, const Point& b2, Point& intersection)
{
    double d = (a2 - a1).cross(b2 - b1);
    if(abs(d) <= EPS){
        if(segmentPointDist(a1, a2, b1) <= EPS){
            intersection = b1;
            return true;
        }
        if(segmentPointDist(a1, a2, b2) <= EPS){
            intersection = b2;
            return true;
        }
        return false;
    }

    double r = (b1 - a1).cross(b2 - b1) / d;
    double s = (b1 - a1).cross(a2 - a1) / d;
    if(r < -EPS || r > 1.0 + EPS || s < -EPS || s > 1.0 + EPS)
        return false;

    intersection = a1 * (1.0 - r) + a2 * r;
    return true;
}

int main()
{
    for(;;){
        int n; // 線分の数
        cin >> n;
        if(n == 0)
            return 0;

        vector<Point> p1(n), p2(n); // 線分の端点
        for(int i=0; i<n; ++i)
            cin >> p1[i].x >> p1[i].y >> p2[i].x >> p2[i].y;

        Point s, g;
        cin >> s.x >> s.y >> g.x >> g.y;

        vector<Point> p; // 線分の交点
        p.push_back(s);
        p.push_back(g);
        for(int i=0; i<n; ++i){
            for(int j=0; j<i; ++j){
                Point intersection;
                if(segmentsIntersection(p1[i], p2[i], p1[j], p2[j], intersection)){
                    bool same = false;
                    for(unsigned k=0; k<p.size(); ++k){
                        if(p[k].dist(intersection) < EPS)
                            same = true;
                    }
                    if(!same)
                        p.push_back(intersection);
                }
            }
        }

        int m = p.size(); // 線分の交点の数
        vector<vector<int> > edges(m);
        for(int i=0; i<m; ++i){
            for(int j=0; j<i; ++j){
                bool connect = false;
                for(int k=0; k<n; ++k){
                    if(segmentPointDist(p1[k], p2[k], p[i]) < EPS && segmentPointDist(p1[k], p2[k], p[j]) < EPS)
                        connect = true;
                }
                if(connect){
                    edges[i].push_back(j);
                    edges[j].push_back(i);
                }
            }
        }

        map<pair<int, int>, double> check;
        multimap<double, pair<int, int> > mm;
        for(unsigned i=0; i<edges[0].size(); ++i){
            check[make_pair(0, edges[0][i])] = 0.0;
            mm.insert(make_pair(0.0, make_pair(0, edges[0][i])));
        }

        double ret = -1.0;
        while(!mm.empty()){
            double cost = mm.begin()->first;
            int prev = mm.begin()->second.first;
            int curr = mm.begin()->second.second;
            mm.erase(mm.begin());
            if(cost > check[make_pair(prev, curr)] + EPS)
                continue;
            if(curr == 1){
                ret = cost;
                break;
            }

            for(unsigned i=0; i<edges[curr].size(); ++i){
                int next = edges[curr][i];
                double theta = (p[next] - p[curr]).dot(p[curr] - p[prev]) / (p[next] - p[curr]).length() / (p[curr] - p[prev]).length();
                theta = min(1.0, max(-1.0, theta));
                theta = acos(theta);
                double cost2 = cost + theta;

                if(check.find(make_pair(curr, next)) == check.end() || cost2 < check[make_pair(curr, next)] - EPS){
                    check[make_pair(curr, next)] = cost2;
                    mm.insert(make_pair(cost2, make_pair(curr, next)));
                }
            }
        }

        if(ret < -0.5){
            cout << -1 << endl;
        }else{
            ret *= 180 / PI;
            cout << fixed << setprecision(10) << ret << endl;
        }
    }
}

Measured memory_bytes: 1396