#include <iostream>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <complex>

#define lb long double
#define sz(vec) ((int)(vec.size()))
#define all(x) x.begin(), x.end()

using namespace std;

#define lp std::complex<double>
#define hsb(x) (31 - __builtin_clz(x))

const int D = 19;
const int NN = (1 << D);
const lb tau = 4.0 * acos(0);

//this function returns the reversed version of x with b bits
int rev(unsigned int x, int b){ //lots of trust
	x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1));
	x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2));
	x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4));
	x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8));
	//https://a...content-available-to-author-only...d.com/5-way-to-reverse-bits-of-an-integer/ method 4
	return((x >> 16) | (x << 16)) >> (32 - b);
}

//evaluates the roots of unity of poly
//if op == 1, reverses it as well
vector<lp> halfft(const vector<lp>& poly, const vector<lp>& rt, int op = 0){
	vector<lp> ans(sz(poly));
	if(sz(poly) == 1){ //hardcode size 1 polynomials
		ans[0] = poly[0];
		return ans;
	}
	int p2 = hsb(sz(poly)); //2^p2 is the size of the polynomial
	for(int i = 0; i<sz(poly); i++){
		ans[rev(i, p2)] = poly[i]; 
	} //this is the base case of storing each coeff into the reverse bitwise form

	for(int k = 1, n = 2; k<=p2; k++, n *= 2){ //iterate n from small to large and find the answers for the n-th roots at each step
		for(int pos = 0; pos < sz(poly); pos += n){ //solve for some block on the polynomial
			for(int i = 0; i<n/2; i++){
				int i1 = i, i2 = i + n/2;
				lp r1 = ans[pos + i] + rt[i1 * (1 << (p2 - k))] * ans[pos + n/2 + i];
				lp r2 = ans[pos + i] + rt[i2 * (1 << (p2 - k))] * ans[pos + n/2 + i];
				//this is the square sum lemma which states
				//f(x) = f+(x^2) + x * f-(x^2)
				//ans already stores the answers for f+(x^2) and f-(x^2)
				//x is acessed by figuring out which position in rt the root actually corrosponds to
				ans[pos + i1] = r1;
				ans[pos + i2] = r2;
				//by storying r1 and r2 i dont need auxilary memory
				//ans is always written into in a way such that ans[pos + i] has the answer
				//for the index i of the block of [pos, pos + 2^k)
			}
		}
	}
	if(op) //reverse the roots
		reverse(1 + all(ans));
	return ans;
}

vector<lp> fft(const vector<int>& a, const vector<int>& b){
	int s;
	for(s = 1; s<(sz(a) +sz(b)); s*=2); //find the smallest power of 2 the answer polynomial can fit into
	vector<lp> A(s, 0), B(s, 0), rt(s);
	for (int i = 0; i < sz(a); i++) {
		A[i] = a[i];
	}
	for (int i = 0; i < sz(b); i++) {
		B[i] = b[i];
	}
	for(int i = 0; i<s; i++){
		rt[i] = exp(lp(0, tau*(lb)i/(lb)(s))); //precompute the roots
	}
	//make the two size 2^k polynomials A and B
	vector<lp> aa = halfft(A, rt), bb = halfft(B, rt); //halfft A and B
	for(int i = 0; i<sz(aa); i++){
		aa[i] *= bb[i]; //multiply them together
	}	
	vector<lp> ans = halfft(aa, rt, 1); //do the reverse fft on the new product
	for(int i = 0; i<s; i++){
		ans[i] /= (lb)s;	//divide by s and write into the answer	
	}
	ans.resize(sz(a) + sz(b) - 1);
	return ans; 
}


int main(){
  	int n, m;
	cin >> n >> m;
	n++, m++;
	vector<int> p1(n), p2(m);
	for(int i = 0; i<n; i++){
		cin >> p1[i];
	}
	for(int i =0; i<m; i++){
		cin >> p2[i];
	}
	vector<lp> ans = fft(p1, p2);
	for(int i = 0; i<sz(ans); i++){
		cout << (int)round(real(ans[i])) << " ";
	}
	cout << "\n";
	return 0;
}



