#include <bits/stdc++.h>
using namespace std;
long long a, a1, b1;
long long b, a2, b2;
int main() {
  cin >> a1 >> b1;
  cin >> a2 >> b2;
  long long a = a1 * b1;
  long long b = a2 * b2;
  long long t1 = 0, t2 = 0;
  while (a % 3 == 0) {
    a /= 3;
    t1++;
  }
  while (b % 3 == 0) {
    b /= 3;
    t2++;
  }
  long long ans = abs(t1 - t2);
  while (t1 > t2 && a1 % 3 == 0) {
    a1 -= a1 / 3;
    t1--;
  }
  while (t1 > t2 && b1 % 3 == 0) {
    b1 -= b1 / 3;
    t1--;
  }
  while (t2 > t1 && a2 % 3 == 0) {
    a2 -= a2 / 3;
    t2--;
  }
  while (t2 > t1 && b2 % 3 == 0) {
    b2 -= b2 / 3;
    t2--;
  }
  a = a1 * b1;
  b = a2 * b2;
  t1 = t2 = 0;
  while (a % 2 == 0) a /= 2, t1++;
  while (b % 2 == 0) b /= 2, t2++;
  ans += abs(t1 - t2);
  while (t1 > t2 && a1 % 2 == 0) {
    a1 -= a1 / 2;
    t1--;
  }
  while (t1 > t2 && b1 % 2 == 0) {
    b1 -= b1 / 2;
    t1--;
  }
  while (t2 > t1 && a2 % 2 == 0) {
    a2 -= a2 / 2;
    t2--;
  }
  while (t2 > t1 && b2 % 2 == 0) {
    b2 -= b2 / 2;
    t2--;
  }
  if (a1 * b1 != a2 * b2)
    printf("-1\n");
  else {
    cout << ans << endl;
    cout << a1 << " " << b1 << endl;
    cout << a2 << " " << b2 << endl;
  }
}
