sudoku — COCI CONTEST_#1
Task type: batch | Time limit: 1 s | Memory limit: 512 MB | Difficulty: 9
Algorithms: implementation, ad-hoc, grid traversal

# Task Sudoku

Sudoku is a logic-based, combinatorial number-placement puzzle. The objective is to fill a 9 × 9 grid with digits from 1 to 9 in such a way that the following statements hold:

- Each row contains exactly one occurrence of each digit from 1 to 9.
- Each column contains exactly one occurrence of each digit from 1 to 9.
- Each of the nine 3 × 3 subgrids contains exactly one occurrence of each digit from 1 to 9.

For a given not yet finished sudoku grid, determine if there is a mistake in it.

**Note:** It is not necessary to check whether the sudoku grid is solvable.

## Input

The input describes the sudoku grid.

The characters `|`, `-` and `+` frame the 3 × 3 subgrids.

The character `.` represents an empty cell.

All the other characters in the input will be digits from `1` to `9`.

See the examples for clarification.

## Output

Output the word `GRESKA` if there is a mistake in the sudoku board. Otherwise, output the word `OK`.

## Scoring

| Subtask | Points | Constraints                                                                             |
|---------|--------|-----------------------------------------------------------------------------------------|
| 1       | 11     | It's possible to determine whether there is a mistake by only checking the first rule.  |
| 2       | 12     | It's possible to determine whether there is a mistake by only checking the second rule. |
| 3       | 13     | It's possible to determine whether there is a mistake by only checking the third rule.  |
| 4       | 14     | No additional constraints.                                                              |

## Examples

| input         | input         | input         |
|---------------|---------------|---------------|
| +-----------+ | +-----------+ | +-----------+ |
| |52.|...|.81| | |3..|6..|.4 | | |5..|98.|67.| |
| |.39|58....| | |4.9|8.1|..7| | |6..|...|.31| |
| |.8.|.9....| | |..7|.49|6..| | |.2.|613|.4.| |
| +-----------+ | +-----------+ | +-----------+ |
| |24.|...|1.3| | |946|157|8.2| | |.96|8.2|1.7| |
| |1..|.43|.86.| | |.2.|3..|745| | |.28|..5|.9.| |
| |.63|..7|.24| | |.7.|28...| | |7.3|19.|6..| |
| +-----------+ | +-----------+ | +-----------+ |
| |...|1.9|35.| | |...|4...|.5 | | |962|.7.|.1.| |
| |..8|.74|6..| | |8.5|.6.|.2.| | |1.5|...|76.| |
| |31.|86.|7.9| | |734|..8|5..| | |.7.|.5.|9..| |
| +-----------+ | +-----------+ | +-----------+ |
|               |               |               |
| output        | output        | output        |
| OK            | GRESKA        | GRESKA        |
|               |               |               |

### Clarification of the first example:

There is no mistake, so the output is OK.

### Clarification of the second example:

There is a mistake in the ninth column: the digit 5 appears twice; and there is also a mistake in the lower right 3 × 3 subgrid: the digit 5 appears twice.

### Clarification of the third example:

There are two mistakes: the digit 2 appears twice in the second column, and the digit 6 appears twice in the seventh column.

Starter code: