Rescue Beacon

Time limit3sMemory limit128 MB

Problem

While fleeing some old and rather unhappy creditors, Han Solo crash-landed the Millennium Falcon on the ice world of Hoth. Now he must get some kind of emergency signal working before his Wookiee friend Chewbacca freezes solid or gets hungry enough to eat a Han-kabob. Can you help him?

Han salvaged a very bright laser that can be seen from light-years away and figured it would make a good signal. The trouble is that if he simply shines it straight up into the sky, there is almost no chance that someone happens to be in the path of the beam to see it. Meanwhile, Chewbacca was playing with a bunch of highly reflective, many-faceted crystals he found in a nearby cave. In a flash of inspiration, Han realized he could build a rescue beacon by shining the laser down onto a crystal, whose facets would in turn reflect the light back up into the sky in many directions at once!

Figure 1: A simplified, two-dimensional illustration of Han's rescue beacon.

The only thing left is to decide which crystal to use as the reflector. Each crystal is a convex polyhedron whose surface consists solely of perfectly triangular facets, and it can be placed in the beacon in any orientation. The best crystal is the one that reflects the laser beam (parallel rays coming from a single direction) back in the greatest number of directions. In other words, the reflective merit of a crystal is simply the number of facets you can see from a single viewing direction, since those are exactly the facets the laser can hit at the same time. Given the geometry of each crystal, compute the greatest number of directions in which the crystal can reflect the laser.

Input

The input consists of geometric descriptions of the crystals in Chewbacca's collection. Each crystal's description begins with a single line containing an integer $n$ ($4 \le n \le 2000$), the number of facets of the crystal, followed by $n$ lines describing the facets. Each facet is given by 9 integers $x_1\ y_1\ z_1\ x_2\ y_2\ z_2\ x_3\ y_3\ z_3$, where the points $(x_1, y_1, z_1)$, $(x_2, y_2, z_2)$, and $(x_3, y_3, z_3)$ are the vertices of the triangular facet, listed in counter-clockwise order as seen from the outside (in a right-handed coordinate frame). All coordinates satisfy $-2000 \le x_i, y_i, z_i \le 2000$, no single facet has area greater than 200,000, and no two facets face the same direction. When all facets of a crystal are assembled they always form a closed convex polyhedron. Moreover, no crystal has any degeneracy that would make the number of facets the laser can hit ambiguous; that is, the data is built so that whether or not you count facets exactly parallel to the beam does not change the answer. The input ends with a line containing a single $0$, which must not be processed as a crystal.

Output

For each crystal, output a single line containing one integer $m$: the greatest number of directions (facets) in which the crystal can reflect the laser beam at the same time.