Under construction

Still being built. Things may change

Sudoku Checker

Time limit2sMemory limit128 MB

Summary
Given an N^2 by N^2 grid with zeros for blanks, decide whether every row, column, and N by N square holds distinct nonzero numbers.
Level

Easy3 of 10

Topics
Hash map, Implementation, Matrix
Solved
No attempts yet

Problem

Sudoku is a puzzle game played on a board of N2×N2N^2 \times N^2 cells. The cells are grouped into N×NN \times N squares of N×NN \times N cells each. Each cell is either empty or contains a single number between 11 and N2N^2.

A sudoku position is correct when the filled numbers in each row, each column, and each square are all different. The goal of the game is to start from a correct position and fill every empty cell so that the final position is still correct.

Write a routine that determines whether a given position is correct.

Input

The input begins with the integer NN, followed by N4N^4 integers describing the sudoku position. Empty cells are denoted by 00.

Output

Print a single line containing either CORRECT or INCORRECT.

Constraints

  • 1≤N≤101 \le N \le 10.

Examples2

  1. Example 1

    Input
    2
    0 0 0 0
    0 0 0 0
    0 0 2 0
    0 0 0 1
    
    Expected output
    CORRECT
    
  2. Example 2

    Input
    2
    2 1 3 0
    3 2 4 0
    1 3 2 4
    0 0 0 1
    
    Expected output
    INCORRECT