

Let matrix A be |a11 a12 . . . a1m|
|a21 a22 . . . a2m|
. . . . . . . . . .
. . . . . . . . . .
|an1 an2 . . . anm|
Let matrix B be |b11 b12 . . . b1q|
|b21 b22 . . . b2q|
. . . . . . . . . .
. . . . . . . . . .
|bp1 bp2 . . . bpq|
Then,
C = A tensor B = |a11B a12B . . . a1mB|
|a21B a22B . . . a2mB|
. . . . . . . . . . .
. . . . . . . . . . .
|an1B an2B . . . anmB|
Let matrix A be |a11 a12|
|a21 a22|
Let matrix B be |b11 b12|
|b21 b22|
|b31 b32|
Then,
C = A tensor B = |a11B a12B|
|a21B a22B|
= |a11b11 a11b12 a12b11 a12b12|
|a11b21 a11b22 a12b21 a12b22|
|a11b31 a11b32 a12b31 a12b32|
|a21b11 a21b12 a22b11 a22b12|
|a21b21 a21b22 a22b21 a22b22|
|a21b31 a21b32 a22b31 a22b32|
The first line of input contains an integer ‘T' representing the number of test cases.
The first line of each test case contains two integers ‘N’ and ‘M’ denoting the number of rows of the matrix and the number of columns of the first matrix ‘A’.
The next ‘N’ lines contain ‘M’ integers separated by spaces describing rows of matrix ‘A’.
The next line contains two integers ‘P’ and ‘Q’ denoting the number of rows of the matrix and the number of columns of the second matrix ‘B’.
The next ‘P’ lines contain ‘Q’ integers separated by spaces describing rows of matrix ‘B’.
For each test case, on a separate line, output a single row of the Kronecker product matrix.
You do not need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 30
1 <= M <= 30
1 <= P <= 30
1 <= Q <= 30
0 <= A[i][j] <= 10^3
0 <= B[i][j] <= 10^3
Time limit: 1 second
The idea is to multiply each element of the matrix ‘A’ with the matrix ‘B’ and store it in another matrix 'C'.
Since we are multiplying each element of ‘A’ with the matrix ‘B’ the size of ‘ans’ array is N*P X M*Q.
The algorithm is as follows: