#!/usr/bin/ruby
#
# 1033.rb: Kuru-Kuru Robot
#

### constant

DRC_P = 0
DRC_M = 1

### subroutines

# w0 := s*v0+p0, w1 := t*v1+p1
# s*v0+p0 = t*v1+p1 -> s*v0-t*v1=p1-p0
# |s*v0x - t*v1x| = |v0x -v1x| |s| = |p1x-p0x|
# |s*v0y - t*v1y|   |v0y -v1y| |t|   |p1y-p0y|
# |s| = 1/(v0x*(-v1y)-(-v1x)*v0y) |-v1y v1x||p1x-p0x|
# |t|                             |-v0y v0x||p1y-p0y|
# 

def cross_st(w0, w1)
  x00, y00, x01, y01 = w0
  x10, y10, x11, y11 = w1

  v0x, v0y = x01 - x00, y01 - y00
  v1x, v1y = x11 - x10, y11 - y10

  d = v0x * v1y - v0y * v1x
  return nil if d == 0

  px = x10 - x00
  py = y10 - y00

  s = (v1y * px - v1x * py).to_f / d
  t = (v0y * px - v0x * py).to_f / d

  return nil if s < 0.0 || s > 1.0 || t < 0.0 || t > 1.0

  [s * v0x + x00, s * v0y + y00, s, t]
end

def rev_deg(deg)
  deg <= 0 ? deg + 180 : deg - 180
end

def deg_change(deg0, deg1)
  d = deg1 - deg0
  while d < 0
    d += 360
  end
  while d > 360
    d -= 360
  end
  [d, 360 - d].min
end

### main

loop do
  n = gets.to_i
  break if n == 0

  wires = []
  n.times do
    x0, y0, x1, y1 = gets.split.map(&:to_i)
    deg = Math.atan2(y1 - y0, x1 - x0) * 180 / Math::PI
    wires << [x0, y0, x1, y1, deg, rev_deg(deg)]
  end
  #p wires

  sx, sy, gx, gy = gets.split.map(&:to_i)
  #p [sx, sy, gx, gy]

  edges = n.times.map{n.times.map{nil}}

  for i in (0...(n - 1))
    wi = wires[i]
    for j in ((i + 1)...n)
      wj = wires[j]

      st = cross_st(wi, wj)
      if ! st.nil?
        x, y, s, t = st
        edges[i][j] = [s, t]
        edges[j][i] = [t, s]
      end
    end
  end
  #p edges

  start = []
  goal = []

  for i in (0...n)
    wi = wires[i]
    if sx == wi[0] && sy == wi[1]
      start << [i, DRC_P, 0.0, wi[4]]
    elsif sx == wi[2] && sy == wi[3]
      start << [i, DRC_M, 1,0, rev_deg(wi[4])]
    end
    if gx == wi[0] && gy == wi[1]
      goal << [i, 0.0]
    elsif gx == wi[2] && gy == wi[3]
      goal << [i, 1.0]
    end
  end
  #p [start, goal]

  dists = n.times.map{[Float::INFINITY] * 2}
  min_deg = Float::INFINITY
  q = []

  for s0 in start
    q << s0
    dists[s0[0]][s0[1]] = 0.0
  end

  while ! q.empty?
    u = q.min{|a, b| dists[a[0]][a[1]] <=> dists[b[0]][b[1]]}
    q.delete(u)

    ui, ud, us, udeg = u
    du = dists[ui][ud]
    finished = false

    for g0 in goal
      if ui == g0[0] &&
          (ud == DRC_P && us < g0[1] ||
           ud == DRC_M && us > g0[1])
        min_deg = du if min_deg > du
        finished = true
      end
    end
    next if finished

    for vi in (0...n)
      next if edges[ui][vi].nil?
      uvs, vs = edges[ui][vi]

      if ud == DRC_P && us < uvs ||
          ud == DRC_M && us > uvs
        for vd in [DRC_P, DRC_M]
          vdeg = wires[vi][4 + vd]
          degc = deg_change(udeg, vdeg)
          dv = dists[vi][vd]
          if dv > du + degc
            dists[vi][vd] = du + degc
            if dv == Float::INFINITY
              q << [vi, vd, vs, vdeg]
            end
          end
        end
      end
    end
  end
  #p dists

  if min_deg == Float::INFINITY
    puts -1
  else
    puts "%.9f" % min_deg
  end
end