cho.sh
Notes
Loading...

Knight Tour

Time limit

2s

Memory limit

128 MB

Problem

A knight's tour is a path on a chessboard in which a knight visits every square exactly once, and from the last square it can move back to the starting square with a legal knight move.

Each square of a 6×6 chessboard is written as one letter from A through F followed by one digit from 1 through 6. Given the 36 squares visited by a knight in order, determine whether the path is a valid knight's tour.

Input

The input consists of 36 lines, each giving one square in the order visited by the knight. Every square in the input exists on the 6×6 chessboard.

Output

Print Valid if the path is a valid knight's tour. Otherwise, print Invalid.