#include <cstdio>
#include <iostream>
#include <complex>
#include <cmath>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;

#define EPS 1e-8

typedef double D;
typedef complex<D> P;
typedef const P &rP;
typedef pair<int,int> pii;
typedef pair<P,P> seg;
typedef vector<vector<int> > Graph;

namespace std{
	bool operator< (rP a, rP b){
		if(abs(real(a) - real(b)) > EPS){
			return real(a) < real(b);
		}
		return imag(a) + EPS < imag(b);
	}
};

D dot(rP a, rP b){
	return real(a) * real(b) + imag(a) * imag(b);
}

D cross(rP a, rP b){
	return real(a) * imag(b) - imag(a) * real(b);
}

double intersect(const seg &a, const seg &b){
	P da12 = a.second - a.first;
	P db21 = b.first - b.second;
	P dab1 = b.first - a.first;
	double D = cross(da12, db21);
	if(abs(D) > EPS){
		double t = cross(dab1, db21) / D;
		double s = cross(da12, dab1) / D;
		if(-EPS < s && s < 1.0 + EPS){
			return t;
		}
	}
	return 1e99;
}

enum{
	LEFT = 1, RIGHT = 2, ON = 4, FRONT = 8, BACK = 16
};
int ccw(P a, P b, P c){
	b -= a;
	c -= a;
	D r = cross(b, c);
	if(r > EPS){ return LEFT; }
	if(r < -EPS){ return RIGHT; }
	if(dot(b, c) < -EPS){ return BACK; }
	if(abs(b) + EPS < abs(c)){ return FRONT; }
	return ON;
}

bool merge_if_able(seg &s, const seg &t){
	if(abs(cross(s.second - s.first, t.second - t.first)) > EPS){
		return false;
	}
	if(ccw(s.first, t.first, s.second) & (LEFT | RIGHT)){
		return false;
	}
	if(ccw(s.first, s.second, t.first) == FRONT){ return false; }
	if(ccw(t.first, t.second, s.first) == FRONT){ return false; }
	s = seg(min(s.first, t.first), max(s.second, t.second));
	return true;
}

void mergeseg(vector<seg> &vsg){
	for(int i = 0; i < vsg.size(); ++i){
		if(vsg[i].second < vsg[i].first){
			swap(vsg[i].second, vsg[i].first);
		}
	}

	int inc;
	for(int i = 0; i < vsg.size(); i += inc){
		inc = 1;
		for(int j = i + 1; j < vsg.size(); ++j){
			if(merge_if_able(vsg[i], vsg[j])){
				inc = 0;
				vsg[j--] = vsg.back();
				vsg.pop_back();
			}
		}
	}
}

void segarrange(vector<seg> ss, vector<P> &ps, Graph &g){
	mergeseg(ss);

	set<P> sps(ps.begin(), ps.end());
	for(int i = 0; i < ss.size(); ++i){
		sps.insert(ss[i].first);
		sps.insert(ss[i].second);
		P dif = ss[i].second - ss[i].first;
		for(int j = i + 1; j < ss.size(); ++j){
			double t = intersect(ss[i], ss[j]);
			if(-EPS < t && t < 1.0 + EPS){
				sps.insert(ss[i].first + t * dif);
			}
		}
	}
	ps.assign(sps.begin(), sps.end());

	g.assign(ps.size(), vector<int>());
	for(int i = 0; i < ss.size(); ++i){
		vector<pair<D,int> > v;
		for(int j = 0; j < ps.size(); ++j){
			if(ccw(ss[i].first, ss[i].second, ps[j]) == ON){
				v.push_back(make_pair(norm(ps[j] - ss[i].first), j));
			}
		}
		sort(v.begin(), v.end());
		for(int j = 1; j < v.size(); ++j){
			int t = v[j-1].second;
			int u = v[j].second;
			g[t].push_back(u);
			g[u].push_back(t);
		}
	}
}

double pi = acos(-1.0);

struct state{
	int now, prev;
	double r;
	bool operator< (const state &s) const{
		return r > s.r;
	}
};

double rotangle(rP a, rP b, rP c){
	double r = abs(arg(b - a) - arg(c - b));
	while(r > pi){ r -= 2.0 * pi; }
	return abs(r);
}

void solve(int n){
	D x1, y1, x2, y2;
	vector<seg> vsg(n);
	vector<P> ps(2);
	Graph g;
	for(int i = 0; i < n; ++i){
		scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
		vsg[i] = seg(P(x1, y1), P(x2, y2));
	}
	scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);
	ps[0] = P(x1, y1);
	ps[1] = P(x2, y2);

	segarrange(vsg, ps, g);
	vector<vector<D> > d(ps.size(), vector<D>(ps.size(), 1e99));
	int start = lower_bound(ps.begin(), ps.end(), P(x1, y1)) - ps.begin();
	int goal = lower_bound(ps.begin(), ps.end(), P(x2, y2)) - ps.begin();

	priority_queue<state> pq;
	for(int i = 0; i < g[start].size(); ++i){
		int t = g[start][i];
		pq.push((state){t, start, 0.0});
		d[t][start] = 0.0;
	}
	while(!pq.empty()){
		state s = pq.top();
		pq.pop();
		if(d[s.now][s.prev] != s.r){ continue; }
		if(s.now == goal){
			printf("%.10f\n", s.r / pi * 180.0);
			return;
		}

		for(int i = 0; i < g[s.now].size(); ++i){
			int t = g[s.now][i];
			double r = s.r + rotangle(ps[s.prev], ps[s.now], ps[t]);
			if(d[t][s.now] > r){
				d[t][s.now] = r;
				pq.push((state){t, s.now, r});
			}
		}
	}
	
	puts("-1");
}

int main(){
	int n;
	while(scanf("%d", &n), n){
		solve(n);
	}
}

Measured memory_bytes: 1384