Given a matrix A and a matrix B, their **Kronecker product** C = A tensor B, also called their matrix direct product, is an matrix.

A tensor B = |a_{11}B a_{12}B| |a_{11}b_{11} a_{11}b_{12} a_{12}b_{11} a_{12}b_{12}|

|a_{21}B a_{22}B| = |a_{11}b_{21} a_{11}b_{22} a_{12}b_{21} a_{12}b_{22}|

|a_{11}b_{31} a_{11}b_{32} a_{12}b_{31} a_{12}b_{32}|

|a_{21}b_{11} a_{21}b_{12} a_{22}b_{11} a_{22}b_{12}|

|a_{21}b_{21} a_{21}b_{22} a_{22}b_{21} a_{22}b_{22}|

|a_{21}b_{31} a_{21}b_{32} a_{22}b_{31} a_{22}b_{32}|

**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[][].

**Constraints:**

1<=T<=50

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

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

**Example:**

**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

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

makeitdonesolo | 64 |

ShubhamJain18 | 64 |

Bishnu Dev Panda | 54 |

DanishBansal | 50 |

abhithakur588 | 50 |

Bishnu Dev Panda | 777 |

yk12 | 512 |

okayboss | 490 |

DevMittal | 472 |

VijethaShastri | 431 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.