Curling up the cube

A paper cube can be made up from six paper squares Given an projection (map) of the cube, you are to determine its correctness. A projection is correct, if a cube can be made up from it. Input The first line is the number of test cases, followed by a blank line. For each test case, input contains a projection represented as a 6 × 6 grid containing six ones and 30 zeroes, separated by spaces. 1’s represent the paper squares. All squares are placed immediately to each other, so that each square is connected with at least one other square. Each test case will be separated by a single line. Output For each test case, your program should print ‘correct’ if cube can be made up from the given project, or ‘incorrect’ otherwise. Print a blank line between the outputs for two consecutive test cases. Sample Input 2 000000 000100 000100 001110 000100 000000 000000 000110 001100 000110 000000 000000 Sample Output correct incorrect