LogiQuest

185. Valid Sudoku

MediumHash Set

Check whether a partially filled 9×9 Sudoku board is valid: no digit repeats in any row, column or 3×3 box. Empty cells are .. Print YES or NO.

Input format

9 lines of 9 characters (digits or .)

Output format

YES or NO

Example 1

Input

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

Output

YES

Example 2

Input

83..7....
6..195...
.98....6.
8...6...3
4..8.3..1
7...2...6
.6....28.
...419..5
....8..79

Output

NO

Constraints

Exactly 9 lines.

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…