Hill encryption (devised by mathematician Lester S. Hill in 1929) is a technique that makes use of matrices and modular arithmetic. It is ideally used with an alphabet that has a prime number of characters, so we'll use the $$$37$$$ character alphabet A, B, $$$\ldots$$$, Z, 0, 1, $$$\ldots$$$, 9, and the space character. The steps involved are the following:
then the first vector is transformed as follows:
This method can be generalized to work with any $$$n \times n$$$ encryption matrix in which case the initial plaintext is broken up into vectors of length $$$n$$$. For this problem you will be given an encryption matrix and a plaintext and must compute the corresponding ciphertext.
Input begins with a line containing a positive integer $$$n \leq 10$$$ indicating the size of the matrix and the vectors to use in the encryption. After this are $$$n$$$ lines each containing $$$n$$$ non-negative integers specifying the encryption matrix. After this is a single line containing the plaintext consisting only of characters in the $$$37$$$-character alphabet specified above.
Output the corresponding ciphertext on a single line.
3 30 1 9 4 23 7 5 9 13 ATTACK AT DAWN
FPLSFA4SUK2W9K3
6 26 11 23 14 13 16 6 7 32 4 29 29 26 19 30 10 30 11 6 28 23 5 24 23 6 24 1 27 24 20 13 9 32 18 20 18 MY HOVERCRAFT IS FULL OF EELS
W4QVBO0NJG5 Y76H5A6XHR11BV670Z
| Name |
|---|


