#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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9TSVpFID0gMjA7CmNvbnN0IGludCBURU4gPSAxMDsKCnZvaWQgbXVsdGlwbHkoaW50IGFbXSwgaW50IHgsIGludCBwcm9kdWN0W10pIHsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IGFbMF07ICsraSkgewogICAgICAgIHByb2R1Y3RbaV0gKz0gYVtpXSAqIHg7CiAgICAgICAgcHJvZHVjdFtpICsgMV0gKz0gcHJvZHVjdFtpXSAvIFRFTjsKICAgICAgICBwcm9kdWN0W2ldICU9IFRFTjsKICAgICAgICBpbnQgaiA9IGk7IAogICAgICAgIHdoaWxlIChwcm9kdWN0W2ogKyAxXSA+PSBURU4pIHsKICAgICAgICAgICAgKytqOwogICAgICAgICAgICBpZiAocHJvZHVjdFswXSA8IGopIHsKICAgICAgICAgICAgICAgICsrcHJvZHVjdFswXTsKICAgICAgICAgICAgfQogICAgICAgICAgICBwcm9kdWN0W2ogKyAxXSArPSBwcm9kdWN0W2pdIC8gVEVOOwogICAgICAgICAgICBwcm9kdWN0W2pdICU9IFRFTjsKICAgICAgICB9CiAgICB9CiAgICBpZiAocHJvZHVjdFtwcm9kdWN0WzBdICsgMV0pIHsKICAgIAkrK3Byb2R1Y3RbMF07CiAgICB9Cn0KCmludCBtYWluKCkgewogICAgaW50IGFbTUFYX1NJWkUgKyAxXSA9IHswfSwgeCwgcHJvZHVjdFtNQVhfU0laRSArIDFdID0gezB9OwogICAgZm9yIChpbnQgaSA9IDA7IGkgPD0gYVswXTsgKytpKSB7CiAgICAgICAgY2luID4+IGFbaV07CiAgICB9CiAgICBjaW4gPj4geDsKICAgIG11bHRpcGx5KGEsIHgsIHByb2R1Y3QpOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPD0gcHJvZHVjdFswXTsgKytpKSB7CiAgICAgICAgY291dCA8PCBwcm9kdWN0W2ldIDw8ICcgJzsKICAgIH0KICAgIHJldHVybiAwOwp9