Start

2017-09-13 00:00 CEST

PSU Meeting 1

End

2017-09-20 00:00 CEST
The end is near!
Contest is over.
Not yet started.
Contest is starting in -72 days 0:07:28

Time elapsed

168:00:00

Time remaining

0:00:00

Problem H
Eight Queens

In the game of chess, the queen is a powerful piece. It can attack by moving any number of spaces in its current row, in its column or diagonally.

In the eight queens puzzle, eight queens must be placed on a standard $8 \times 8$ chess board so that no queen can attack another. The center figure below shows an invalid solution; two queens can attack each other diagonally. The figure on the right shows a valid solution. Given a description of a chess board, your job is to determine whether or not it represents a valid solution to the eight queens puzzle.

\includegraphics[width=0.7\textwidth ]{chess}
Figure 1: Queen movement (left), invalid solution (center), valid solution (right).

Input

Input will contain a description of a single chess board, given as eight lines of eight characters each. Input lines will consist of only the characters ‘.’ and ‘*’. The ‘.’ character represents an empty space on the board, and the ‘*’ character represents a queen.

Output

Print a single line of output. Print the word “valid” if the given chess board is a valid solution to the eight queens problem. Otherwise, print “invalid”.

Sample Input 1 Sample Output 1
*.......
..*.....
....*...
......*.
.*......
.......*
.....*..
...*....
invalid
Sample Input 2 Sample Output 2
*.......
......*.
....*...
.......*
.*......
...*....
.....*..
..*.....
valid