#include <bits/stdc++.h>
using namespace std;

void fastIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

int N, M;

typedef complex<long double> cp;
const long double PI = acos(-1);

void fft(vector<cp> &a, bool invert = false){
    int n = (int)a.size();
    // if n == 1 then A(w^0) = A(0) = a0
    if (n == 1){
        return;
    }
    //Let A_even(x) = a0+a2*x+a4*x^2+a6*x^3+...
    //A_odd(x) = a1+a3*x+a5*x^2+a7*x^3+...
    vector<cp> even, odd;
    //0 2 4 6 8..
    for (int i = 0; i < n; i += 2){
        even.push_back(a[i]);
    }
    //1 3 5 7 9..
    for (int i = 1; i < n; i += 2){
        odd.push_back(a[i]);
    }
    /**
     * divide and conquer - calculate what A_even(x^2) and A_odd(x^2) are, the sizes of each are n/2
     * Put n roots of unity into A in this function, put n/2 roots of unity into the recursive one
     * */
    fft(even, invert);
    fft(odd, invert);
    //in each iteration, w = e^(2*pi*i/n)
    //initially w = e^0, then multiply by e^(2*pi/n)
    cp w(1, 0), mult(cos(2*PI/n), sin(2*PI/n));
    //in the inverted case everything is to the power of -1
    if (invert) mult = {cos(-2*PI/n), sin(-2*PI/n)};
    for (int i = 0; i < n/2; i++){
        //A(x) = A_even(x^2)+x*A_odd(x^2), let x = w_n^i
        //if i < n/2, A(w_n^i) = A_even(w_(n/2)^(2*i)) + w_n^i * A_odd(w_(n/2)^(2*i))
        a[i] = even[i]+w*odd[i];
        //if i >= n/2, the same equation holds but i > n/2 would be out of bounds of A_even and A_odd
        //rearranging and substituting eq for i < n/2 yields the equation for i >= n/2
        a[i+n/2] = even[i]-w*odd[i];
        //in the inverted matrix, everything is divided by n at the end
        //since n = 2^(layers), divide the inverted matrix by 2 each time does the same thing as dividing by n at the end
        if (invert){
            a[i] /= 2;
            a[i+n/2] /= 2;
        }
        //update w_n^i
        w *= mult;
    }
}

int main(){
    fastIO();
    cin >> N >> M;
    N++, M++;
    vector<cp> acoeff, bcoeff;
    for (int i = 1; i <= N; i++){
        int a; cin >> a;
        acoeff.push_back(a);
    }
    for (int i = 1; i <= M; i++){
        int b; cin >> b;
        bcoeff.push_back(b);
    }
    //array sizes must be a power of 2 since the size is divided by 2 in each recursive layer
    int ind = 0;
    while (N+M > (1<<ind)){
        ind++;
    }
    for (int i = N; i < (1<<ind); i++) acoeff.push_back(0);
    for (int i = M; i < (1<<ind); i++) bcoeff.push_back(0);
    //compute A(w_n^0), A(w_n^1), ...
    fft(acoeff);
    //compute B(w_n^0), B(w_n^1), ...
    fft(bcoeff);
    //convolution - C(w_n^i) = A(w_n^i)*B(w_n^i)
    vector<cp> c((1<<ind));
    for (int i = 0; i < (1<<ind); i++){
        c[i] = acoeff[i]*bcoeff[i];
    }
    //inverted matrix for fft - calculate C(w_n^(-i))
    fft(c, true);
    vector<long long> result(1<<ind);
    for (int i = 0; i < N+M-1; i++){
        result[i] = round(c[i].real());
        cout << result[i] << " ";
    }
}