#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<iomanip>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl
#define F first
#define S second
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double EPS = 1e-8, INF = 1e12, PI = acos(-1.0);
typedef complex<long double> P;
namespace std{
	bool operator<(const P& a, const P& b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
	bool operator==(const P &a, const P &b){
		return abs(a - b) < EPS;
	}
}
inline double cross(const P& a, const P& b){ return imag(conj(a)*b); }
inline double dot(const P& a, const P& b){ return real(conj(a)*b); }
struct L : public vector<P>{
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};
typedef vector<P> G;

inline int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if(cross(b, c) > EPS)   return +1;		// counter clockwise
	if(cross(b, c) < -EPS)   return -1;		// clockwise
	if(dot(b, c) < -EPS)     return +2;		// c--a--b on line
	if(norm(b) + EPS < norm(c)) return -2;		// a--b--c on line
	return 0;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
P crosspoint(const L &l, const L &m) {
  long double A = cross(l[1] - l[0], m[1] - m[0]);
  long double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}
int n;
vector<vi> e;

int main(){
	while(cin >> n, n){
		vector<L> ls;
		P s, t;
		rep(i, n){
			int x, y, X, Y;
			cin >> x >> y >> X >> Y;
			ls.pb(L(P(x, y), P(X, Y)));
			if(ls[i][1] < ls[i][0]) swap(ls[i][0], ls[i][1]);
		}
		cin >> s.real() >> s.imag() >> t.real() >> t.imag();
		
		bool er[50] = {};
		while(1){
			bool update = 0;
			rep(i, n) if(!er[i]) rep(j, i) if(!er[j]){
				if(abs(cross(ls[i][0] - ls[i][1], ls[j][0] - ls[j][1])) > EPS) continue;
				bool ok = 0;
				rep(k, 2) rep(l, 2){
					if(ccw(ls[k ? i : j][l], ls[k ? j : i][0], ls[k ? j : i][1]) == 2) ok = 1;
					if(ls[i][k] == ls[j][l]) ok = 1;
				}
				if(!ok) continue;
				
				ls[i][0] = min(ls[i][0], ls[j][0]);
				ls[i][1] = max(ls[i][1], ls[j][1]);
				er[j] = 1;
			}
			if(!update) break;
		}
		vector<L> tmp;
		rep(i, n) if(!er[i]) tmp.pb(ls[i]);
		ls = tmp;
		
		n = ls.size();
		map<P, int> id;
		G ps;
		rep(i, n) rep(j, i) if(intersectSS(ls[i], ls[j])){
			P p = crosspoint(ls[i], ls[j]);
			if(!id.count(p)) id[p] = ps.size(), ps.pb(p);
		}
		if(!id.count(s)) id[s] = ps.size(), ps.pb(s);
		if(!id.count(t)) id[t] = ps.size(), ps.pb(t);
		
		int m = ps.size();
		e.clear(); e.resize(m);
		rep(i, n){
			vi v;
			rep(j, m) if(ps[j] == ls[i][0] || ps[j] == ls[i][1] ||
				ccw(ps[j], ls[i][0], ls[i][1]) == 2) v.pb(j);
			rep(j, v.size()) rep(k, j) e[v[j]].pb(v[k]), e[v[k]].pb(v[j]);
		}
		
		set<pi> v;
		priority_queue<pair<long double, pi> > q;
		each(i, e[id[s]]){
			q.push(mp(0, mp(*i, id[s])));
		}
		while(!q.empty()){
			int c = q.top().S.F, p = q.top().S.S;
			long double co = q.top().F;
			q.pop();
			if(v.count(mp(c, p))) continue;
			v.insert(mp(c, p));
			if(ps[c] == t){
				cout << fixed << setprecision(20) << -co * 180 / PI << endl;
				goto END;
			}
			
			each(i, e[c]) if(ps[*i] != ps[c] && !v.count(mp(*i, c))){
				long double a = arg((ps[*i] - ps[c]) / (ps[c] - ps[p]));
				q.push(mp(co - abs(a), mp(*i, c)));
			}
		}
		cout << "-1" << endl; END:;
	}
	return 0;
}

Measured memory_bytes: 1436