#include <iostream>
using namespace std;

const int MAX_SIZE = 20;
const int TEN = 10;

void multiply(int a[], int x, int product[]) {
    for (int i = 1; i <= a[0]; ++i) {
        product[i] += a[i] * x;
        product[i + 1] += product[i] / TEN;
        product[i] %= TEN;
        int j = i; 
        while (product[j + 1] >= TEN) {
            ++j;
            if (product[0] < j) {
                ++product[0];
            }
            product[j + 1] += product[j] / TEN;
            product[j] %= TEN;
        }
    }
    if (product[product[0] + 1]) {
    	++product[0];
    }
}

int main() {
    int a[MAX_SIZE + 1] = {0}, x, product[MAX_SIZE + 1] = {0};
    for (int i = 0; i <= a[0]; ++i) {
        cin >> a[i];
    }
    cin >> x;
    multiply(a, x, product);
    for (int i = 0; i <= product[0]; ++i) {
        cout << product[i] << ' ';
    }
    return 0;
}