MOD = 998244353
n, m = gets.split.map &:to_i
a = gets.split.map &:to_i
b = gets.split.map &:to_i

a_bn = 0
a.each do |a_i|
  a_bn = a_bn * MOD + a_i
end

b_bn = 0
b.each do |b_i|
  b_bn = b_bn * MOD + b_i
end

c_bn = a_bn * b_bn
c = []
(n + m - 1).times do
  c.unshift c_bn % MOD
  c_bn /= MOD
end

puts c.join(" ")