What's on the Grille?

Recover the original grid message from the encrypted letters by rotating the grille, or report that the grille is invalid.

Easy3SimulationMatrixInterviewNo attempts yetTime limit1sMemory limit256 MB

Problem

The grille cipher goes back to 1550, when Girolamo Cardano first described it. The version used here comes from the late 1800s and works as follows. Write the message on an n×nn \times n grid row by row, from top to bottom, then cover the grid with a card that has holes punched in it. That card is the grille.

To encrypt, write down the letters showing through the holes, row by row. Then rotate the grille 90 degrees clockwise, write down the letters that now show, and repeat this two more times. The holes have to be chosen so that every letter of the message shows through a hole at some point, and such a layout is not hard to build.

The figure below shows the grid for "Send more monkeys", padded with one random letter, being encrypted as "noeesrksdmnyemoj".

Figure I.1

If the message is longer than the grid, the first n2n^2 letters are written into the grid and encrypted, then the next n2n^2 letters, and so on, with the final grid padded with random letters when needed. This problem only deals with messages of length exactly n2n^2.

Given an encrypted message and the grille used to produce it, recover the original message. One more condition applies. The given grille may be invalid, meaning that over the four rotations its holes do not expose every cell of the grid exactly once. In that case you have to report that the message cannot be decrypted.

Input

The first line contains a positive integer nn, the size of the grid and of the grille. (n10n \le 10)

Each of the next nn lines describes one row of the grille, using . for a hole and X for a non-hole.

The last line contains the encrypted message, made up only of lowercase letters. This line always has n2n^2 characters.

Output

Print the decrypted text as a single string with no spaces, or invalid grille if the grille is invalid.