#include <cstdio>
#include <cassert>
#include <cstring>

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

const int maxMem = (int)1e8;

int mem[maxMem];
int mpos = 0;

inline int *my_alloc( int n )
{
  int *res = mem + mpos;
  mpos += n;
  assert(mpos <= maxMem);
  return res;
}

// n = 2^k
// c = a * b
// a.length = n [0...n-1]
// b.length = n
// c.length = 2n
// Число 123, n=4, a = {3, 2, 1, 0}
void Karatsuba( int n, int *c, int *a, int *b )
{
  if (n <= 8)
  {
    forn(i, 2 * n)
      c[i] = 0;
    forn(i, n)
      forn(j, n)
        c[i + j] += a[i] * b[j];
    return;
  }
  // a = (a1, a2)
  // b = (b1, b2)
  // d = a1 * b1
  // e = a2 * b2
  // f = (a1 + a2) * (b1 + b2) - d - e
  // c = d + f * x^{n/2} + e * x^n
  int old = mpos;
  int k = n / 2;
  int *f = my_alloc(n);
  int *a12 = my_alloc(k);
  int *b12 = my_alloc(k);

  // Time(n) = n + 3*Time(n/2) = O(n^log3)
  // Count(n) = 3 + 3*Count(n/2) = 3 + 9 + 27 + ... + 3^(logn) = O(n^log3)

  Karatsuba(k, c, a, b); // d = c
  Karatsuba(k, c + n, a + k, b + k); // e = c + n
  forn(i, k)
  {
    a12[i] = a[i] + a[i + k];
    b12[i] = b[i] + b[i + k];
  }
  Karatsuba(k, f, a12, b12); 
  forn(i, n)
    f[i] -= c[i] + c[i + n];
  forn(i, n)
    c[i + k] += f[i];

  mpos = old;
}

const int N = 8;

// base = 10
// base = 10^6
// base*base*length

int a[N], b[N], c[2 * N];

void read( int *a )
{
  static char s[N + 1];
  gets(s);
  int k = 0;
  for (int i = strlen(s) - 1; i >= 0; i--)
    a[k++] = s[i] - '0';
}

void out( int n, int *a )
{
  forn(i, n)
    printf("%d%c", a[n - i - 1], (i < n - 1) ? ' ' : '\n');
}

void carry( int n, int *c )
{
  forn(i, n)
    if (c[i] >= 10)
      c[i + 1] += c[i] / 10, c[i] %= 10;
}

void mul( int *c, int *a, int *b )
{
  Karatsuba(N, c, a, b);
  carry(2 * N, c);
}

int main()
{
  read(a);
  read(b);
  
  mul(c, a, b);

  out(N, a);
  out(N, b);
  out(2 * N, c);
}