require "fiddle/import"
module GMP
	extend Fiddle::Importer
	dlload "libgmp.so"

	MPZStruct = struct [
		"int mp_alloc",
		"int mp_size",
		"unsigned long *mp_d"]

	extern "void __gmpz_init(void *)"
	extern "void __gmpz_clear(void *)"

	extern "void __gmpz_set_ui(void *, unsigned long)"
	extern "unsigned long __gmpz_get_ui(void *)"

	extern "void __gmpz_import(void *rop, size_t count, int order, size_t size, int endian, size_t nails, void *op)"
	extern "void *__gmpz_export(void *rop, size_t *count, int order, size_t size, int endian, size_t nails, void *op)"

	extern "void __gmpz_mul(void *, void *, void *)"

	class MPZ
		attr_reader :z

		def initialize
			@z = MPZStruct.malloc
			GMP.__gmpz_init @z
		end

		def import_u64_array(array)
			s = Fiddle::Pointer[array.pack("Q*")]
			GMP.__gmpz_import @z, array.size, 1, 8, 0, 0, s
		end

		def export_u64_array(size)
			c = Fiddle::Pointer.malloc(4)
			s = GMP.__gmpz_export nil, c, 1, 8, 0, 0, @z
			n = c.to_s(4).unpack("L")[0]
			s.to_s(8 * n.to_i).unpack("Q*")
		end

		def get_u32
			GMP.__gmpz_get_ui @z
		end

		def set_u32(u32)
			GMP.__gmpz_set_ui @z, u32
		end

		def mul(a, b)
			GMP.__gmpz_mul @z, a.z, b.z
		end
	end
end

n, m = gets.split.map &:to_i
as = gets.split.flat_map { |s| [0, s.to_i] }
bs = gets.split.flat_map { |s| [0, s.to_i] }

a = GMP::MPZ.new
a.import_u64_array(as)

b = GMP::MPZ.new
b.import_u64_array(bs)

a.mul a, b

r = a.export_u64_array(n + m + 2)
puts r.each_slice(2).map { |(x, _)| (x || 0) % 998244353 }.join(" ")