AtCoder Regular Contest 062
E
Building Cubes with AtCoDeer
AtCoder
⌀ 2655
原题
←F →
翻译中…

Problem Statement

翻译中…

AtCoDeer the deer has $N$ square tiles. The tiles are numbered $1$ through $N$, and the number given to each tile is written on one side of the tile. Also, each corner of each tile is painted in one of the $1000$ colors, which are represented by the integers $0$ between $999$. The top-left, top-right, bottom-right and bottom-left corner of the tile with the number $i$ are painted in color $C_{i,0}, C_{i,1}, C_{i,2}$ and $C_{i,3}$, respectively, when seen in the direction of the number written on the tile (See Figure $1$).

翻译中…

image Figure $1$: The correspondence between the colors of a tile and the input

翻译中…

AtCoDeer is constructing a cube using six of these tiles, under the following conditions:

翻译中…
  • For each tile, the side with the number must face outward.
  • For each vertex of the cube, the three corners of the tiles that forms it must all be painted in the same color.
翻译中…

Help him by finding the number of the different cubes that can be constructed under the conditions. Since each tile has a number written on it, two cubes are considered different if the set of the used tiles are different, or the tiles are used in different directions, even if the formation of the colors are the same. (Each tile can be used in one of the four directions, obtained by $90°$ rotations.) Two cubes are considered the same only if rotating one in the three dimensional space can obtain an exact copy of the other, including the directions of the tiles.

翻译中…

image Figure $2$: The four directions of a tile

翻译中…

Constraints

翻译中…
  • $6≦N≦400$
  • $0≦C_{i,j}≦999 (1≦i≦N , 0≦j≦3)$
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
C_{1,0} C_{1,1} C_{1,2} C_{1,3}
C_{2,0} C_{2,1} C_{2,2} C_{2,3}
:
C_{N,0} C_{N,1} C_{N,2} C_{N,3}

翻译中…

Output

翻译中…

Print the number of the different cubes that can be constructed under the conditions.

翻译中…

样例

Input #1
6
0 1 2 3
0 4 6 1
1 6 7 2
2 7 5 3
6 4 5 7
4 0 3 5
Output #1
1
The cube below can be constructed. ![image](https://atcoder.jp/img/arc062/094fbca5395bfaaea28c98c51230693b.png)
Input #2
8
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
Output #2
144
Input #3
6
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
Output #3
122880
题目信息
题号
arc062_c
时间限制
4 s
内存限制
256 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。