// Arup Guha
// 1/30/2016
// Solution to 2011 MCPC Problem B: Laser Tag
import java.util.*;

public class b {

	final public static int MAXBOUNCE = 7;

	public static int n;
	public static lineseg[] mirrors;
	public static TreeSet<Integer> answers;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		n = stdin.nextInt();

		// Process each case.
		while (n != 0) {

			// Initialize where we store our answers.
			answers = new TreeSet<Integer>();

			// Read in the mirrors.
			mirrors = new lineseg[n];
			for (int i=0; i<n; i++) {
				int x = stdin.nextInt();
				int y = stdin.nextInt();
				pt start = new pt(x, y);
				x = stdin.nextInt();
				y = stdin.nextInt();
				pt end = new pt(x, y);
				mirrors[i] = new lineseg(start, end);
			}

			// Solve it!
			go(new int[MAXBOUNCE], 0);

			// Nothing worked
			if (answers.size() == 0)
				System.out.println("no danger");

			// List the answers in numeric order.
			else {
				boolean printed = false;
				while (answers.size() > 0) {
					if (printed) System.out.print(" ");
					System.out.print(answers.pollFirst());
					printed = true;
				}
				System.out.println();
			}

			// Get next case.
			n = stdin.nextInt();
		}
	}

	public static void go(int[] order, int k) {

		// Evaluate these set of mirrors.
		if (k > 0) eval(order, k);

		// Can't bounce any more.
		if (k == MAXBOUNCE) return;

		// Try each mirror next.
		for (int i=0; i<n; i++) {

			// Can't hit the same mirror twice in a row.
			if (k > 0 && i == order[k-1]) continue;

			// Place this mirror and recurse.
			order[k] = i;
			go (order, k+1);
		}
	}

	// Returns a copy of the original line segments.
	public static lineseg[] copy() {
		lineseg[] list = new lineseg[n];
		for (int i=0; i<n; i++)
			list[i] = new lineseg(new pt(mirrors[i].p1.x, mirrors[i].p1.y), new pt(mirrors[i].p2.x, mirrors[i].p2.y));
		return list;
	}

	// Process the permutation order[0..k-1].
	public static void eval(int[] order, int k) {

		// Just make a copy of the original list.
		lineseg[] list = copy();
		pt target = new pt(0, 0);

		// Go through each mirror.
		for (int i=0; i<k; i++) {

			// Also reflect our target point across the current mirror.
			target = target.reflect(list[order[i]]);

			// Reflect each mirror across the current one.
			for (int j=0; j<n; j++) {
				if (j == order[i]) continue;
				list[j] = list[j].reflect(list[order[i]]);
			}
		}

		// This is the angle of our shot.
		double sol = target.angle();
		if (sol < 0) sol += 2*Math.PI;

		// Line segment defining supposed self shot.
		lineseg shot = new lineseg(new pt(0, 0), target);

		// Keeps track of how far our shot has gone so far.
		double curD = 0;

		// Need to start with the original copy of the mirrors.
		list = copy();

		// Go through each mirror (we just pass through each one)
		for (int i=0; i<k; i++) {

			// See if this mirror is in range.
			double[] cover = list[order[i]].range();
			if (!contains(cover, sol)) return;

			// Calculate our intersection point, and distance from origin.
			pt intersect = shot.intersect(list[order[i]]);
			double dist = intersect.distFromOrigin();

			// This isn't allowed.
			if (dist < curD) return;

			// See where other walls are, do they get in the way?
			for (int j=0; j<n; j++) {

				// Skip our wall.
				if (j == order[i]) continue;

				// This is strange, but we must also skip the previous mirror we just reflected over,
				// since it's currently closer to the origin.
				if (i > 0 && j == order[i-1]) continue;

				// This wall is safe, not in range.
				double[] thiscover = list[j].range();
				if (!contains(thiscover, sol)) continue;

				// Calculate where the ray intersects this other wall.
				pt thisintersect = shot.intersect(list[j]);
				double thisdist = thisintersect.distFromOrigin();

				// This is a problem, we would actually hit this wall first.
				if (thisdist < dist && thisdist > curD) return;
			}

			// New current distance.
			curD = dist;

			// Now, let's move all of our walls.
			for (int j=0; j<n; j++) {
				if (j == order[i]) continue;
				list[j] = list[j].reflect(list[order[i]]);
			}
		}

		// Means the target isn't in the right direction of the shot.
		if (target.distFromOrigin() < curD) return;

		// After last mirror, we must check to make sure a wall doesn't get in the way.
		for (int i=0; i<n; i++) {
			if (i == order[k-1]) continue;
			double[] thiscover = list[i].range();
			if (!contains(thiscover, sol)) continue;
			pt thisintersect = shot.intersect(list[i]);
			double thisdist = thisintersect.distFromOrigin();
			if (thisdist < target.distFromOrigin() && thisdist > curD) return;
		}

		// Convert to degrees, round to nearest integer and map to [0, 360).
		int res = (int)(sol*180/Math.PI+0.5);
		if (res < 0) res += 360;
		if (res >= 360) res -= 360;

		// Put it in our list.
		answers.add(res);
	}

	public static boolean contains(double[] cover, double sol) {

		// Range got flipped backwards, so fix it.
		if (cover[1] - cover[0] > Math.PI) {
			cover[1] -= (2*Math.PI);
			Arrays.sort(cover);
		}

		// This is ugly, but I just want to make sure I don't miss a valid solution.
		while (sol >= cover[0]-1e-9) sol -= 2*Math.PI;
		sol += 2*Math.PI;
		return cover[0] <= sol && sol <= cover[1];
	}
}

class pt {

	public double x;
	public double y;

	public pt(double myx, double myy) {
		x = myx;
		y = myy;
	}

	public pt getVect(pt end) {
		return new pt(end.x-x, end.y-y);
	}

	public double angle() {
		return Math.atan2(y, x);
	}

	public double distFromOrigin() {
		return Math.sqrt(x*x+y*y);
	}

	public pt reflect(lineseg line) {

		pt dir = new pt(line.dir.y, -line.dir.x);

		// Figure out lambda for intersection of ray from pt going towards line.
		double den = det(dir.x, -line.dir.x, dir.y, -line.dir.y);
		double num = det(line.p1.x-x, -line.dir.x, line.p1.y-y, -line.dir.y);
		double lambda = num/den;

		// Now, to get the reflection, just double lambda!
		return new pt(x+2*lambda*dir.x, y+2*lambda*dir.y);
	}

	public static double det(double a, double b, double c, double d) {
		return a*d-b*c;
	}
}

class lineseg {

	public pt p1;
	public pt p2;
	public pt dir;

	public lineseg(pt start, pt end) {
		p1 = start;
		p2 = end;
		dir = start.getVect(end);
	}

	public double[] range() {
		double[] res = new double[2];
		res[0] = p1.angle();
		res[1] = p2.angle();
		for (int i=0; i<2; i++) if (res[i] < 0) res[i] += (2*Math.PI);
		Arrays.sort(res);
		return res;
	}

	public pt intersect(lineseg line) {

		// Figure out lambda for intersection of ray from pt going towards line.
		double den = det(dir.x, -line.dir.x, dir.y, -line.dir.y);
		double num = det(line.p1.x-this.p1.x, -line.dir.x, line.p1.y-this.p1.y, -line.dir.y);
		double lambda = num/den;

		// Plug in lambda to get intersection point.
		return new pt(this.p1.x+lambda*dir.x, this.p1.y+lambda*dir.y);
	}

	public static double det(double a, double b, double c, double d) {
		return a*d-b*c;
	}

	public lineseg reflect(lineseg line) {

		// Get our two new points.
		pt newp1 = p1.reflect(line);
		pt newp2 = p2.reflect(line);

		// Ta da!
		return new lineseg(newp1, newp2);
	}
}