题目描述
Let me introduce an easy method of encryption to you.
Suppose there're N bytes(1 byte = 8 bits) data that are to be encrypted and we want to encrypt them in groups of M bytes, while for the last group we may need to add some zeros to make up M bytes. Then we find out an M*M matrix(Aij)m*m. Now for each group, suppose M bytes are X1, X2, ..., Xm, and we will generate the encrypted data Y1, Y2, ..., Ym from the following equations:
Yi=(X1*AAi1)+(X2*Ai2)+...+(Xm*Aim)
i=1, 2, 3, ..., m
输入
There are multiple cases.
For each case, there are two numbers N and M(1 <= N <= 100, 2 <= M <=1 0) in the first line. In the second line are N numbers to be encrypted (between 0 and 255). While in the following M lines, each line contains M numbers and the jth number in the ith line of these M lines is Aij(0 <= Aij <= 255). Numbers in the same line are seperated by spaces.
Input will be ended by end of file.
输出
For each case, output one line of the encrypted data. If the encrypted data contains K numbers, use K-1 spacesto separate them.
4 2
1 2 3 4
0 1
1 0
1 2
1
3 1
0 1
10 10
100 100 100 100 100 100 100 100 100 100
100 100 100 100 100 100 100 100 100 100
0 1 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 1
2 1 4 3
3 0
100000 100 100 100 100 100 100 100 100 100