#include <bits/stdc++.h>
using namespace std;
long long a1, b1, a2, b2;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long check(long long k) {
  while (k % 2 == 0) k /= 2;
  while (k % 3 == 0) k /= 3;
  return k;
}
long long get(long long k) {
  long long cnt = 0;
  while (k % 2 == 0) k /= 2, cnt++;
  while (k % 3 == 0) k /= 3, cnt++;
  return cnt;
}
long long get_tat(long long k) {
  long long ans = 1;
  while (k % 2 == 0) ans *= 2, k /= 2;
  while (k % 3 == 0) ans *= 3, k /= 3;
  return ans;
}
long long pow_mod(long long p, long long k) {
  long long ans = 1;
  while (k) {
    if (k & 1) ans *= p;
    p = p * p;
    k >>= 1;
  }
  return ans;
}
long long change(long long a, long long k) {
  long long ans = gcd(a, k);
  a /= ans, k /= ans;
  while (a % 3 == 0) a /= 3, a *= 2;
  ans *= gcd(a, k);
  return ans;
}
int main() {
  cin >> a1 >> a2 >> b1 >> b2;
  if (check(a1) * check(a2) != check(b1) * check(b2))
    cout << -1 << endl;
  else {
    long long tmp1 = get_tat(a1 * a2), tmp2 = get_tat(b1 * b2);
    long long anssquare = check(a1) * check(a2);
    long long ans;
    long long g = gcd(tmp1, tmp2);
    anssquare *= g;
    tmp1 /= g, tmp2 /= g;
    if (tmp1 == 1 || tmp2 == 1) {
      long long t, cnt = 0;
      if (tmp1 == 1)
        t = tmp2;
      else
        t = tmp1;
      while (t % 2 == 0) t /= 2, cnt++;
      while (t % 3 == 0) t /= 3, cnt += 2;
      ans = cnt;
    } else {
      long long a = get(tmp1), b = get(tmp2);
      if (tmp1 % 3 == 0) {
        ans = a + abs(a - b);
        anssquare *= pow_mod(1ll * 2, min(a, b));
      } else {
        ans = b + abs(a - b);
        anssquare *= pow_mod(1ll * 2, min(a, b));
      }
    }
    a1 = change(a1, anssquare);
    a2 = anssquare / a1;
    b1 = change(b1, anssquare);
    b2 = anssquare / b1;
    cout << ans << endl;
    cout << a1 << " " << a2 << endl;
    cout << b1 << " " << b2 << endl;
  }
  return 0;
}
