a1,a2=map(int,input().split())
lista=[]
listb=[]
count=0
sum=0
for i in range(a1):
list1=list(map(int,input().split()))
lista.append(list1)
b1,b2=map(int,input().split())
for i in range(b1):
list2=list(map(int,input().split()))
listb.append(list2)
if a2!=b1:
print("Error: "+str(a2)+" != "+str(b1))
else:
print(str(a1)+" "+str(b2))
#list3=[[0 for i in range(b2)]for i in range(a1)]
for i in range(a1):
for j in range(b2):
for k in range(a2):
sum+=(lista[i][k]*listb[k][j])
count+=1
if (count!=b2):
print(sum,end=" ")
else:
print(sum)
count=0
sum=0