#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_D
require "matrix"

n,m = gets.split.map(&:to_i)

nArr = []
n.times.each {
    nArr.push(gets.split.map(&:to_i))
}
a = Matrix.rows(nArr)

mArr = []
m.times.each {
    mArr.push(gets.split.map(&:to_i))
}
b = Matrix.rows(mArr)

puts (a * b).to_a