#K57412. Sudoku Board Validator

    ID: 30415 Type: Default 1000ms 256MiB

Sudoku Board Validator

Sudoku Board Validator

This problem requires you to validate one or more Sudoku board configurations.

Each board consists of 9 rows of 9 characters representing digits ('1'-'9') or an empty cell ('.'). A valid Sudoku board must satisfy the following conditions:

  • No duplicate digits in any row.
  • No duplicate digits in any column.
  • No duplicate digits in any of the 3x3 sub-boxes.

Boards are provided in sequence, with each board consisting of 9 consecutive lines followed by a line containing END which marks the end of that board's input. Your task is to validate each board and output Valid if the board configuration meets the Sudoku criteria, or Invalid otherwise.

inputFormat

Input is given via standard input (stdin) as multiple lines. Each Sudoku board consists of 9 lines containing 9 characters each. After a board, a line containing the word "END" appears. There may be multiple boards in the input, concatenated one after the other.

outputFormat

For each valid board encountered in the input, output a single line containing either "Valid" if the board is a valid Sudoku configuration, or "Invalid" if it is not. The output is printed to standard output (stdout).## sample

53..7....
6..195...
.98....6.
8...6...3
4..8.3..1
7...2...6
.6....28.
...419..5
....8..79
END
Valid

</p>