#include <bits/stdc++.h>
using namespace std;
long long a1, b1, a2, b2;
int main() {
  while (scanf("%I64d%I64d%I64d%I64d", &a1, &b1, &a2, &b2) == 4) {
    long long c1 = a1 * b1, c2 = a2 * b2;
    int cntc12 = 0, cntc13 = 0, cntc22 = 0, cntc23 = 0;
    while (c1 % 2 == 0) {
      c1 /= 2;
      cntc12++;
    }
    while (c1 % 3 == 0) {
      c1 /= 3;
      cntc13++;
    }
    while (c2 % 2 == 0) {
      c2 /= 2;
      cntc22++;
    }
    while (c2 % 3 == 0) {
      c2 /= 3;
      cntc23++;
    }
    if (c1 != c2) {
      puts("-1");
      continue;
    }
    int cc = min(cntc13, cntc23), ans = 0;
    int cc1 = cntc13 - cc, cc2 = cntc23 - cc;
    if (cc1 > 0) {
      cntc12 += cc1;
      ans += cc1;
      while (cc1) {
        if (a1 % 3 == 0) {
          a1 = a1 / 3 * 2;
          cc1--;
        }
        if (cc1 && b1 % 3 == 0) {
          b1 = b1 / 3 * 2;
          cc1--;
        }
      }
    }
    if (cc2 > 0) {
      cntc22 += cc2;
      ans += cc2;
      while (cc2) {
        if (a2 % 3 == 0) {
          a2 = a2 / 3 * 2;
          cc2--;
        }
        if (cc2 && b2 % 3 == 0) {
          b2 = b2 / 3 * 2;
          cc2--;
        }
      }
    }
    cc = min(cntc12, cntc22);
    cc1 = cntc12 - cc, cc2 = cntc22 - cc;
    if (cc1 > 0) {
      ans += cc1;
      while (cc1) {
        if (a1 % 2 == 0) {
          a1 = a1 / 2;
          cc1--;
        }
        if (cc1 && b1 % 2 == 0) {
          b1 = b1 / 2;
          cc1--;
        }
      }
    }
    if (cc2 > 0) {
      ans += cc2;
      while (cc2) {
        if (a2 % 2 == 0) {
          a2 = a2 / 2;
          cc2--;
        }
        if (cc2 && b2 % 2 == 0) {
          b2 = b2 / 2;
          cc2--;
        }
      }
    }
    printf("%d\n", ans);
    printf("%I64d %I64d\n", a1, b1);
    printf("%I64d %I64d\n", a2, b2);
  }
  return 0;
}
