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

typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<vector<vector<double> > > mat;

const int INF = 1 << 29;
const double EPS = 1e-7;

namespace std{
  bool operator == (const P &a, const P &b){
    return fabs(real(a-b)) < EPS && fabs(imag(a-b)) < EPS;
  }
}

struct data{
  P p;
  set<int> s;
  data(P p):p(p){s.clear();}
};

struct state{
  int prev,now;
  double cost;
  state(int p=0, int n=0, double c=0):prev(p),now(n),cost(c){}
  bool operator < (const state &s) const {
    return cost > s.cost;
  }
};

int n;
L l[50];
P s, g;
vector<data> v;
mat cost;


double dot(P a, P b){ return real(conj(a)*b); }

double cross(P a, P b){ return imag(conj(a)*b); }

int ccw(P a, P b, P c){
    b -= a;
    c -= a;
    if(cross(b,c) > EPS) return 1;
    if(cross(b,c) < -EPS) return -1;
    if(dot(b,c) < -EPS) return 2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}

bool isIntersect(L s1, L s2){
    return ( ccw(s1.first,s1.second,s2.first) * ccw(s1.first,s1.second,s2.second) <= 0 &&
             ccw(s2.first,s2.second,s1.first) * ccw(s2.first,s2.second,s1.second) <= 0 );
}

P crossPoint(pair<P,P> l, pair<P,P> m){
    double A = cross(l.second - l.first, m.second - m.first);
    double B = cross(l.second - l.first, l.second - m.first);
    if(fabs(A) < EPS && fabs(B) < EPS) return m.first;
    else if(fabs(A) >= EPS) return m.first + B / A * (m.second - m.first);
}

void makeP(){
  v.clear();

  for(int i=0;i<n;i++){
    bool f=false,f2=false;
    for(int j=0;j<v.size();j++){
      if(v[j].p == l[i].first){
        v[j].s.insert(i);
        f = true;
      }
      if(v[j].p == l[i].second){
        v[j].s.insert(i);
        f2 = true;
      }
    }
    if(!f){
      v.push_back(data(l[i].first));
      v[v.size()-1].s.insert(i);
    }
    if(!f2){
      v.push_back(data(l[i].second));
      v[v.size()-1].s.insert(i);
    }

    for(int j=i+1;j<n;j++){
      if(!isIntersect(l[i],l[j])) continue;
      P p = crossPoint(l[i],l[j]);
      f = false;
      for(int k=0;k<v.size();k++){
        if(v[k].p == p){
          v[k].s.insert(i);
          v[k].s.insert(j);
          f = true;
          break;
        }
      }
      if(!f){
        v.push_back(data(p));
        v[v.size()-1].s.insert(i);
        v[v.size()-1].s.insert(j);
      }
    }
  }
}

double calcCost(P p1, P p2, P p3){
  double A = abs(p2-p3);
  double B = abs(p3-p1);
  double C = abs(p1-p2);
  return 180.0 - acos((B*B + C*C - A*A) / (2.0 * B * C)) * 180.0 / M_PI;
};

void makeCost(){
  cost.assign(v.size(), vector<vector<double> >(v.size(), vector<double>(v.size(),(double)INF)));
  for(int i=0;i<v.size();i++){
    for(int j=0;j<v.size();j++){
      if(i == j) continue;

      bool f = false;
      for(int k=0;k<n;k++){
        if(v[i].s.find(k) != v[i].s.end() && v[j].s.find(k) != v[j].s.end()){
          f = true;
          break;
        }
      }
      if(!f) continue;

      for(int k=0;k<v.size();k++){
        if(i == k || j == k) continue;

        f = false;
        for(int l=0;l<n;l++){
          if(v[k].s.find(l) != v[k].s.end() && v[j].s.find(l) != v[j].s.end()){
            f = true;
            break;
          }
        }
        if(f) cost[i][j][k] = calcCost(v[j].p, v[i].p, v[k].p);
      }
    }
  }
}

void solve(){
  priority_queue<state> Q;
  state u,u2;
  vector<vector<double> > d(v.size(), vector<double>(v.size(), (double)INF));

  if(s == g){
    cout << 0 << endl;
    return;
  }

  for(int i=0;i<v.size();i++){
    if(s == v[i].p){
      u.prev = i;
      break;
    }
  }
  for(int i=0;i<v.size();i++){
    for(set<int>::iterator it = v[u.prev].s.begin(); it != v[u.prev].s.end(); it++){
      if(i != u.prev && v[i].s.find(*it) != v[i].s.end()){
        u.now = i;
        d[u.prev][i] = 0;
        Q.push(u);
      }
    }
  }

  while(!Q.empty()){
    u = Q.top();
    Q.pop();

    if(v[u.now].p == g){
      printf("%.7f\n",u.cost);
      return;
    }

    for(int i=0;i<v.size();i++){
      u2 = state(u.now, i, d[u.prev][u.now] + cost[u.prev][u.now][i]);
      if(u2.cost < d[u.now][i]){
        d[u.now][i] = u2.cost;
        Q.push(u2);
      }
    }
  }
  cout << -1 << endl;
}

int main(){
  while(cin >> n && n){
    double x,y,x2,y2;
    for(int i=0;i<n;i++){
      double x,y,x2,y2;
      cin >> x >> y >> x2 >> y2;
      l[i] = L(P(x,y),P(x2,y2));
    }
    cin >> x >> y >> x2 >> y2;
    s = P(x,y);
    g = P(x2,y2);

    makeP();
    makeCost();
    solve();
  }
}

Measured memory_bytes: 3244