A unit cube is a 1x1x1 cube, whose corners have integer x, y, and z coordinates. Two unit cubes are connected when they share a face. A 3-dimensional solid object (solid, for short) is a non-empty connected set of unit cubes (see Figure 1). The volume of a solid is the number of unit cubes it contains. A block is a solid with volume at most 4. Two blocks have the same type when one can be obtained from the other by translations and rotations (not reflections). There are exactly 12 block types (see Figure 2). The colors in the figures only help to clarify the structure of the solids; they have no other meaning.
A set D of blocks is a decomposition of a solid S when the union of all blocks in D equals S, and no two distinct blocks in D have a unit cube in common.
Your task is to write a program that, given a description of a solid S, determines a smallest set of blocks into which S can be decomposed. It only needs to report the types of these blocks as often as they occur in the decomposition.

Your program is to read from standard input. The first line contains the volume V of the solid (1 <= V <= 50). The remaining V lines contain three integers x, y, z, being the coordinate triple of its corner that minimizes x + y + z, each identifying one unit cube of the solid (1 <= x, y, z <= 7).

Your program is to write to standard output. The first line must contain one integer M, being the smallest number of blocks into which the input solid can be decomposed.

提交代码