Matrix Coverage

Time Limit: 1000 ms Memory Limit: 65536 KiB

Problem Description

Now you have got an easy problem of matrix coverage.

As you know, a matrix is a rectangular arrangement of numbers.R*C matrix means a matrix with R rows and every row has C columns.Now you have two matrices,one of which is a Ra*Ca matrix and we call it matrix A,while the other one is a Rb*Cb matrix and we call it matrix B.Your task is to replace a certain area of matrix A with matrix B.I will give you the position of the top left point of the area in the format (P,Q).P stands for the row of top left point and Q stands for the column where it is in.For example,(1,1) means the top left point is in the first row and first column of matrix A.Then the area will be replaced by matrix B.You should be careful that when the size of matrix B exceeds the area given by the task ,you only need to use part of the matrix B to replace the area.For example matrix A and B are shown in Figure-1.When the top left point is in (2,2),you can get the result matrix C after the area is replaced as it is shown in Figure-2,however when the top left point is in (3,5),you can get the result matrix D as it is shown in Figure-2.

Figure-1 

 

 

Figure-2

Input

There are mulitple test cases.The first line of input is a positive integer T ,(0 < T < 1000),which stands for there are T test cases.For each test case,there are two positive integers Ra,Ca,both of them are no more than 20,indicating the number of rows and columns of matrix A.For the next Ra lines,each line has Ca integers.Then the next line gives two positive integers Rb,Cb,both of them are no more than 20,indicating the number of rows and columns of matrix B.For the next Rb lines,each line has Cb integers.The last line of each test case gives the position (P ,Q) of the top left point of the area in matrix A.It guarantees that 0 < P <= Ra and 0 < Q <= Ca .

Output

For each test case, you should output the result matrix after the given area of matrix A is replaced by matrix B.For each row,output a space between two integers.Output a blank line after each test case.

Sample Input

2
5 6
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
4 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
2 2
5 6
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
4 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
3 5

Sample Output

0 0 0 0 0 0
0 1 2 3 4 0
0 1 2 3 4 0
0 1 2 3 4 0
0 1 2 3 4 0

0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 1 2
0 0 0 0 1 2
0 0 0 0 1 2

Hint

 

Source

山东理工大学第三届ACM程序设计竞赛