Laser Tag

Time limit1sMemory limit128 MB

Problem

A laser-tag arena contains several upright, double-sided flat mirrors, each tall enough that the arena can be treated as a 2D plane seen from above. A mirror reflects your laser beam, so a beam you fire can bounce off one or more mirrors and travel back to the exact point you fired from — hitting you. Your task is to find every initial firing angle whose beam comes back to the firing point, so that those angles can be avoided.

The mirrors are not perfectly reflective, so only beams that return after at most 7 reflections need to be considered. Put the firing point at the origin of a Cartesian coordinate system, with positive $x$ pointing right and positive $y$ pointing up. Each mirror is a straight segment of negligible thickness whose both faces reflect. A firing angle is measured in degrees counterclockwise from the positive $x$-axis and rounded to the nearest degree, giving an integer from $0$ to $359$.

Input

The input contains one or more datasets. Each dataset begins with a line holding the number of mirrors $n$ ($1 \le n \le 7$). Each of the next $n$ lines contains four integers $x_1\ y_1\ x_2\ y_2$ — the coordinates of the two ends of one mirror. All coordinates are integers whose absolute value is less than $1000$. No two mirrors intersect or touch, and no mirror passes through the origin.

The input ends with a line containing a single $0$, which is not processed.

Output

For each dataset, print one line. Consider every beam that leaves the origin and returns to the origin after at most $7$ reflections; round each such firing angle to the nearest degree and normalize it to the range $0 \le a \le 359$. Remove duplicate angles and print the remaining integers in increasing order, separated by single spaces. If no beam returns to the origin, print no danger instead.

No beam grazes the exact end of a mirror. Although the reported angles are rounded, all internal computation should use double-precision floating point. No output line exceeds $79$ characters.