import java.util.Scanner;
//Other imports go here, Do NOT change the class name
class MatrixMultiplication
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
while(x>0)
{
int r1,c1,r2,c2,i,j;
r1=sc.nextInt();
c1=sc.nextInt();
int arr[][]=new int[r1][c1];
for(i=0;i