#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
struct D {
  long long a, b;
  int p2, p3;
  long long x;
  int d[100][100];
  int m[100][100];
  void check(queue<pair<int, int> >& q, int a, int b, int x, int y) {
    if (a >= 0 && b >= 0 && d[a][b] == INF) {
      d[a][b] = x;
      m[a][b] = y;
      q.push(make_pair(a, b));
    }
  }
  void read() {
    scanf("%lld%lld", &a, &b);
    x = 1LL * a * b;
    p2 = p3 = 0;
    while (x % 2 == 0) p2++, x /= 2;
    while (x % 3 == 0) p3++, x /= 3;
    for (int i = 0; i < 100; i++) fill(d[i], d[i] + 100, INF);
    queue<pair<int, int> > q;
    q.push(make_pair(p2, p3));
    d[p2][p3] = 0;
    while (!q.empty()) {
      int a = q.front().first, b = q.front().second;
      q.pop();
      check(q, a - 1, b, d[a][b] + 1, 2);
      check(q, a + 1, b - 1, d[a][b] + 1, 3);
    }
  }
  void trace(int i, int j) {
    vector<int> x;
    while (!(i == p2 && j == p3)) {
      x.push_back(m[i][j]);
      if (m[i][j] == 2)
        i++;
      else
        i--, j++;
    }
    reverse(x.begin(), x.end());
    for (int mm : x) {
      if (mm == 2) {
        if (a % 2 == 0)
          a /= 2;
        else
          b /= 2;
      } else {
        if (a % 3 == 0)
          a /= 3, a *= 2;
        else
          b /= 3, b *= 2;
      }
    }
    printf("%lld %lld\n", a, b);
  }
} DA, DB;
void solve() {
  DA.read();
  DB.read();
  if (DA.x != DB.x) {
    puts("-1");
    return;
  }
  int a = 0, b = 0;
  for (int i = 0; i < 100; i++)
    for (int j = 0; j < 100; j++)
      if (DA.d[i][j] + DB.d[i][j] < DA.d[a][b] + DB.d[a][b]) a = i, b = j;
  printf("%d\n", DA.d[a][b] + DB.d[a][b]);
  DA.trace(a, b);
  DB.trace(a, b);
}
int main() {
  solve();
  return 0;
}
