Difficulty Level: Easy

Submissions: 48 Accuracy:


[Kronecker Product]

Given a {m}\times{n} matrix A and a {p}\times{q} matrix B, their Kronecker product C = A tensor B, also called their matrix direct product, is an {(mp)}\times{(nq)} matrix.

A tensor B = |a11B a12B|             |a11b11 a11b12 a12b11 a12b12|

                      |a21B a22B|      =    |a11b21 a11b22 a12b21 a12b22|

                                                      |a11b31 a11b32 a12b31 a12b32|

                                                      |a21b11 a21b12 a22b11 a22b12|

                                                      |a21b21 a21b22 a22b21 a22b22|

                                                      |a21b31 a21b32 a22b31 a22b32|


INPUT: The first line consists of an integer T i.e. the number of test cases. The first line of each test case contains Four Integer m, n, p, q  denoting the size of the Matrix. Here (m, n ) denoting the size of first and (p, q ) denoting the size of the second matrix. Next m lines contain n integers separated by space and another P lines contain q integers also separated by space.

OUTPUT: For each test case in a new line output will be the space-separated values of the matrix C[][].

1 <= m , n , p , q <= 20

1<= A[i][j] , B[i][j] <= 100


Input :     1
            2  2  2  2   
            1 2       
            3 4        
            0 5 
            6 7

Output:      0  5  0  10
             6  7  12 14
             0  15 0  20
             18 21 24 28

** For More Input/Output Examples Use 'Expected Output' option **

Author: Nishant_Singh

Set Default Code

It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use, generate link and share the link here.