#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

static const double EPS = 1e-10;
const double INF = 1e12;
typedef complex<double> P,point;
 
std::istream& operator>>(std::istream& is,P& p)
{
	is >> p.real() >> p.imag();
	return is;
}

typedef vector<P> G,polygon;
struct L : public vector<P> {L(const P &a, const P &b) {push_back(a); push_back(b);} L(){push_back(P(0,0)); push_back(P(0,0));}};
namespace std {bool operator < (const P& a, const P& b) {return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);} }
double cross(const P& a, const P& b) {return imag(conj(a)*b);}
double dot(const P& a, const P& b) {return real(conj(a)*b);}

bool intersectLL(const L &l, const L &m) {return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;}

int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)   return +1;
	if (cross(b, c) < 0)   return -1;
	if (dot(b, c) < 0) return +2;
	if (norm(b) < norm(c)) return -2;
	return 0;
}
 
 
P crosspoint(const L &l, const L &m) {
	double A = cross(l[1] - l[0], m[1] - m[0]);
	double B = cross(l[1] - l[0], l[1] - m[0]);
	if (abs(A) < EPS && abs(B) < EPS) return m[0];
	return m[0] + B / A * (m[1] - m[0]);
}
bool intersectSP(const L &s, const P &p) {return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS;}
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;}

struct Node{
	int id;
	double dir;
	double cost;
	Node(int id,double dir,double cost) : id(id),dir(dir),cost(cost){}
};
bool operator <(const Node &a,const Node &b){
	return a.cost > b.cost;
}

double PI = acos(-1);
double fix(double x){
	while( x >= 2 * PI ) x -= 2 * PI;
	while( x < 0) x += 2 * PI;
	return x;
}
int main(){
	int n;
	while(cin >> n && n){
		L l[n];
		for(int i = 0 ; i < n ; i++){
			cin >> l[i][0] >> l[i][1];
		}
		vector<P> tar,tar_;
		for(int i = 0 ; i < n ; i++){
			tar.push_back(l[i][0]);
			tar.push_back(l[i][1]);
			for(int j = 0 ; j < n ; j++){
				if( intersectSS(l[i],l[j]) ) tar.push_back(crosspoint(l[i],l[j]));
			}
		}
		
		P s,g;
		cin >> s >> g;
		tar.push_back(s);
		tar.push_back(g);
		sort(tar.begin(),tar.end());
		for(int i = 0 ; i < tar.size() ; i++)
			if( !i || abs(tar[i-1]-tar[i]) > EPS ) tar_.push_back(tar[i]);
		tar = tar_;
		
		vector< vector<int> > connect(tar.size());
		for(int i = 0 ; i < tar.size() ; i++){
			for(int j = i+1 ; j < tar.size() ; j++){
				for(int k = 0 ; k < n ; k++){
					if( intersectSP(l[k],tar[i]) && intersectSP(l[k],tar[j]) ){
						connect[i].push_back(j);
						connect[j].push_back(i);
						break;
					}
				}
			}
		}
		priority_queue<Node> Q;
		for(int i = 0 ; i < tar.size() ; i++)
			if( abs(tar[i]-s) < EPS ){
				Q.push(Node(i,-114514,0));
			}
		
		map< pair<int,long long> , int> done;
		double res = -1;
		while( Q.size() ){
			Node q = Q.top(); Q.pop();
			if( done[make_pair(q.id,(long long)(q.dir*10000000))]++ ) continue;
			P my = tar[q.id];
			if( abs(my-g) < EPS ){
				res = q.cost;
				break;
			}
			for(int i = 0 ; i < connect[q.id].size() ; i++){
				int eid = connect[q.id][i];
				P ene = tar[eid];
				ene -= my;
				double rad = atan2(ene.imag(),ene.real());
				rad = fix(rad);
				double diff = fabs(q.dir-rad);
				diff = min(2*PI-diff,diff);
				
				if( q.dir == -114514 ) diff = 0;
				Q.push(Node(eid,rad,q.cost+diff));
			}
		}
		if( res < 0 ){
			cout << -1 << endl;
		}else{
			printf("%.10lf\n",res*180/PI);
		}
	}
}

Measured memory_bytes: 1440