n, m = gets.split(' ') b = gets.split(' ') a = [''] (1..n.to_i).each do |j| a << gets.chop end if b[0] == "+" (1..n.to_i).each do |j| (1..m.to_i).each do |i| printf "#{a[j].to_i + b[i].to_i}" if i != m.to_i printf " " end end printf "\n" end else (1..n.to_i).each do |j| (1..m.to_i).each do |i| printf "#{a[j].to_i * b[i].to_i}" if i != m.to_i printf " " end end printf "\n" end end