#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;

constexpr double EPS = 1e-9;

struct point {
	double x, y;
	explicit point(double x_ = 0.0, double y_ = 0.0):x(x_), y(y_) {}
	point(const point &p):x(p.x), y(p.y) {}

	point operator+ (const point &p) const {
		return point(x + p.x, y + p.y);
	}

	point operator- (const point &p) const {
		return point(x - p.x, y - p.y);
	}

	point operator* (double s) const {
		return point(x * s, y * s);
	}

	point operator* (const point &p) const {
		return point(x * p.x - y * p.y, x * p.y + y * p.x);
	}

	point operator/ (double s) const {
		return point(x / s, y / s);
	}

	bool operator< (const point &p) const {
		return x + EPS < p.x || (abs(x - p.x) < EPS && y + EPS < p.y);
	}

	bool operator== (const point &p) const {
		return abs(x - p.x) < EPS && abs(y - p.y) < EPS;
	}
};

double angle(const point &p) {
	return atan2(p.y, p.x);
}

double norm(const point &p) {
	return p.x * p.x + p.y * p.y;
}

double abs(const point &p) {
	return sqrt(norm(p));
}

double dot(const point &a, const point &b) {
	return a.x * b.x + a.y * b.y;
}

double cross(const point &a, const point &b) {
	return a.x * b.y - a.y * b.x;
}

struct segment {
	point a, b;
	segment(const point &a_, const point &b_):a(a_), b(b_){}
};

int ccw(const point &a, point b, point c) {
	b = b - a;
	c = c - a;
	const double tmp = cross(b, c);
	if(tmp > EPS) return 1; // ccw
	if(tmp < -EPS) return -1; // cw
	if(dot(b, c) < 0) return 2; // c, a, b 順に一直線上
	if(norm(b) < norm(c)) return -2; // a, b, c 順に一直線上
	return 0; //a, c, b 順で一直線上
}

bool intersect(const segment &s, const segment &t) {
	return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0
		&& ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

bool intersect(const segment &s, const point &p) {
	return ccw(s.a, s.b, p) == 0;
}

// 先にintersectで交差判定をすること
point crosspoint(const segment &s, const segment &t) {
	const double tmp = cross(s.b - s.a, t.b - t.a);
	if(abs(tmp) < EPS) { // 一直線上
		if(intersect(s, t.a)) return t.a;
		if(intersect(s, t.b)) return t.b;
		if(intersect(t, s.a)) return s.a;
		return s.b;
	}
	return t.a + (t.b - t.a) * (cross(s.b - s.a, s.b - t.a) / tmp);
}

struct edge {
	int to;
	double cost, theta;
	int rev;
	edge(int to_, double cost_, double theta_, int rev_):to(to_), cost(cost_), theta(theta_), rev(rev_) {}
};

typedef vector<vector<edge>> graph;

graph arrangement(const vector<segment> &segments, vector<point> &points) {
	const int n = segments.size();
	points.clear();

	for(int i = 0; i < n; ++i) {
		const auto &s1 = segments[i];
		points.emplace_back(s1.a);
		points.emplace_back(s1.b);

		for(int j = i + 1; j < n; ++j) {
			const auto &s2 = segments[j];
			if(intersect(s1, s2)) {
				points.emplace_back(crosspoint(s1, s2));
			}
		}
	}

	sort(points.begin(), points.end());
	points.erase(unique(points.begin(), points.end()), points.end());

	const int V = points.size();
	graph G(V);

	for(const auto &s : segments) {
		vector<pair<double, int>> vs;
		for(int i = 0; i < V; ++i) {
			if(intersect(s, points[i])) {
				vs.emplace_back(abs(s.a - points[i]), i);
			}
		}

		sort(vs.begin(), vs.end());
		for(int i = 1; i < static_cast<int>(vs.size()); ++i) {
			const int v = vs[i].second;
			const int u = vs[i - 1].second;
			const double d = vs[i].first - vs[i - 1].first;
			G[v].emplace_back(u, d, angle(points[u] - points[v]) * 180.0 / M_PI, G[u].size());
			G[u].emplace_back(v, d, angle(points[v] - points[u]) * 180.0 / M_PI, G[v].size() - 1);
		}
	}

	return G;
}

typedef tuple<double, int, int> state; // dist, v, from edge

double dijkstra(int s, int g, const graph &G) {
	const int n = G.size();
	if(s >= n || g >= n) return -1;
	if(s == g) return 0;


	vector<map<int, double>> dist(n);
	priority_queue<state, vector<state>, greater<state>> que;

	for(const auto &e : G[s]) {
		dist[e.to][e.rev] = 0.0;
		que.push(state(0.0, e.to, e.rev));
	}

	while(!que.empty()) {
		int v, from;
		double d;
		tie(d, v, from) = que.top();
		que.pop();

		if(dist[v][from] + EPS < d) continue;
		if(v == g) return d;

		const double current_angle = G[v][from].theta - 180.0;

		for(const auto &e : G[v]) {
			double diff_angle = e.theta - current_angle;
			if(diff_angle > 180.0) diff_angle -= 360.0;

			const double next_dist = d + abs(diff_angle);
			if(!dist[e.to].count(e.rev) || dist[e.to][e.rev] > next_dist + EPS) {
				dist[e.to][e.rev] = next_dist;
				que.push(state(next_dist, e.to, e.rev));
			}
		}
	}
	

	return -1;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	for(int n; cin >> n && n;) {
		vector<segment> segments;
		segments.reserve(n);

		for(int i = 0; i < n; ++i) {
			int x1, y1, x2, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			segments.emplace_back(point(x1, y1), point(x2, y2));
		}

		vector<point> points;
		const graph G = arrangement(segments, points);

		int sx, sy, gx, gy;
		cin >> sx >> sy >> gx >> gy;

		const int s = lower_bound(points.begin(), points.end(), point(sx, sy)) - points.begin();
		const int g = lower_bound(points.begin(), points.end(), point(gx, gy)) - points.begin();

		const double ans = dijkstra(s, g, G);
		if(ans < 0) {
			cout << "-1" << endl;
		}
		else {
			cout << ans << endl;
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1368