Cuboid is a 3D shape which is commonly used in computer graphics. Cuboids are often used as background elements in games or other applications where the user interacts with them. They have been used in movies such as “The Matrix” and “Toy Story”. There are many different types of cuboids, each having its own special characteristics:

Cuboid Bounding Boxes (CBBs) – These are rectangular boxes containing one or more cubic faces.

Cuboid Faces – A face is a geometric feature which is not necessarily connected to any other features. For example, the corner of a cube may contain one or more faces.

Cuboid Face Area – The area enclosed by all the faces of a cuboid. Each face has an equal amount of surface area, so it makes sense that their total area would be equal to the sum of their areas.

Cuboid Volume – The volume of a cuboid. This includes the volume of the faces, but does not include the volume of the cube itself.

Cuboid Vertices – A vertex is a point on a cuboid face. Each face has at least one vertex, so there must be at least two vertices per face.

Your task is to take a list of unit vectors (two dimensional vectors of length one and pointing along the positive x and y axis) and determine if they represent a cuboid with known dimensions.

Input for your program will come from standard input in the form of a string containing a list of unit vectors in the order it is read by your program, each followed by a single newline. Your program will then read in and store these vectors in an array. Your program should then read a second string from standard input, which is the name of the array holding the unit vector list. The program should then loop through all of the vectors in the array, and determine if they represent a cuboid with known dimensions.

The Dimensions of a cuboid are described by giving its width, height, and depth. A cuboid’s dimensions can be described by up to three positive integers which represent the width, height, and depth in that order. A cuboid with a width of 2, a height of 3, and a depth of 5 would be described as 23125.

Your program should check if the vector list represents a cuboid with the given dimensions. If the vector list does not represent a cuboid with the given dimensions then your program should output a message saying so. If the vector list does represent a cuboid with the given dimensions then your program should output a message saying so.

In the input for this problem, each unit vector will be represented by one number between 0 and 4, inclusive. This number should be interpreted as the index of an array element holding that unit vector.

There may be more than one list of unit vectors. Each list of unit vectors should be separated from the next by a blank line.

The first line of input will contain two integers: the number of test cases and the number of unit vectors in each test case. Each test case will be followed by a newline.

The maximum number of unit vectors in a test case is 100.

There will always be at least one blank line in the input and the input will not contain any extra characters (such as spaces). The number of lines in the input will be between 50 and 2000.

The unit vectors will all be different.

Sample Input

0 5 4 2 1 3 0 4 1 0 2 2 0 0 Sample Output List dimension 23125 Input list: 2 3 0 4 1 0 2 2 0 0 Correct! Input list: 1 4 1 3 1 0 1 1 0 0 Incorrect, does not have correct dimensions.

Source:

__Sources & references used in this article:__

Displaced fractures of the cuboid by BJ Sangeorzan… – The Journal of Bone …, 1990 – online.boneandjoint.org.uk

Spatio-temporal depth cuboid similarity feature for activity recognition using depth camera by L Xia, JK Aggarwal – Proceedings of the IEEE conference on …, 2013 – cv-foundation.org

Cuboid subluxation in ballet dancers by P Marshall, WG Hamilton – The american journal of sports …, 1992 – journals.sagepub.com

Cuboid syndrome by SG Newell, A Woodle – The Physician and sportsmedicine, 1981 – Taylor & Francis

Interactive images: cuboid proxies for smart image manipulation. by Y Zheng, X Chen, MM Cheng, K Zhou, SM Hu… – ACM Trans. Graph., 2012 – Citeseer

The rational cuboid revisited by J Leech – The American Mathematical Monthly, 1977 – Taylor & Francis