Acesrc is fond of cube nets. If we cut some edges of a cube, the surface of the cube can be unfolded into 2-dimensional space, and the resulting flat shape is called a cube net. There are 11 essentially different cube nets, listed below.
In this problem, we consider a generalization of the cube net, called cube hypernet. For each face of a cube, we divide it into $k \times k$ small square cells. If we cut some edges of these small cells, the surface of the cube can be unfolded into 2-dimensional space, then the resulting flat shape is a cube hypernet. Clearly, cube nets are just a special type of cube hypernets where $k = 1$. The following picture illustrates a cube hypernet and explains how it is formed.
Identifying cube nets is a relatively easy job; however, this might not be true for cube hypernets. Here comes the challenge. Given a flat shape composed of small squares, determine whether it is a cube hypernet.