//NAME : Paige Maguire
//SCHOOL : Kalamazoo AMSC
//DIVISION : Intermediate-5
//LAST MODIFIED : 3-18-11
//PROBLEM ID : ACSL
Intermediate Matrix Encryption
//DESCRIPTION : Decodes
an encrypted message.
//10 1 8 18 3 19
14 28 45 18 30 0 1 1 1
//8 39 71 103 69
18 29 41 32 3 2 1 1
//12 14 9 24 23 1
13 22 9 19 23 13 2 1 2 1 1
//14 15 15 21 23
24 21 26 21 22 23 13 13 23 23 5 6 1 1
//8 18 14 1 11 20
19 15 25 0 1 1 1
import
java.util.*;
public class
PMaguireIntMatrixEncryption
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
for(int j=0; j<5; j++)
{
int numValues = in.nextInt();
int[][] matrix = new
int[2][(numValues+1)/2];
for(int k=0;
k<(numValues+1)/2; k++)
{
matrix[0][k] =
in.nextInt();
}
for(int y=0;
y<(numValues+1)/2; y++)
{
if(numValues % 2 == 1
&& y == ((numValues+1)/2)-1)
{
matrix[1][y] = 27;
}
else
{
matrix[1][y] =
in.nextInt();
}
}
int[] encoding = new int[4];
for(int m=0; m<4; m++)
{
encoding[m] =
in.nextInt();
}
int[][] decoded = new
int[2][(numValues+1)/2];
int[] inverse = new int[4];
int multiply = 1 /
(encoding[0]*encoding[3] - encoding[1]*encoding[2]);
inverse[0] =
multiply*encoding[3];
inverse[1] =
multiply*encoding[1]*-1;
inverse[2] =
multiply*encoding[2]*-1;
inverse[3] =
multiply*encoding[0];
for(int n=0;
n<(numValues+1)/2; n++)
{
decoded[0][n] =
matrix[0][n]*inverse[0] + matrix[1][n]*inverse[1];
decoded[1][n] =
matrix[0][n]*inverse[2] + matrix[1][n]*inverse[3];
}
for(int t=0;
t<(numValues+1)/2; t++)
{
while(decoded[0][t] <
0)
{
decoded[0][t] +=
27;
}
while(decoded[1][t] <
0)
{
decoded[1][t] +=
27;
}
if(decoded[0][t] >
27)
{
decoded[0][t] %=
27;
}
if(decoded[1][t] >
27)
{
decoded[1][t] %=
27;
}
if(decoded[0][t] == 0 ||
decoded[0][t] == 27)
{
decoded[0][t] =
32;
}
if(decoded[1][t] == 0 ||
decoded[1][t] == 27)
{
decoded[1][t] =
32;
}
}
for(int b=0;
b<(numValues+1)/2; b++)
{
for(int c=0; c<2;
c++)
{
if(decoded[c][b]
!= 32)
System.out.print((char)(decoded[c][b]
+ 64));
else
System.out.print((char)(decoded[c][b]));
}
}
System.out.println();
}
}
}