#include <bits/stdc++.h>
using namespace std;
inline const int getint() {
  int r = 0, k = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') k = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) r = r * 10 + c - '0';
  return k * r;
}
long long ans, a1, b1, a2, b2, t1, t2;
int main() {
  cin >> a1 >> b1 >> a2 >> b2;
  long long a = a1 * b1, b = a2 * b2;
  while (a % 3 == 0) ++t1, a /= 3;
  while (b % 3 == 0) ++t2, b /= 3;
  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 (t1 < t2 && a2 % 3 == 0) a2 -= a2 / 3, --t2;
  while (t1 < t2 && b2 % 3 == 0) b2 -= b2 / 3, --t2;
  a = a1 * b1, b = a2 * b2;
  t1 = t2 = 0;
  while (a % 2 == 0) ++t1, a /= 2;
  while (b % 2 == 0) ++t2, b /= 2;
  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 (t1 < t2 && a2 % 2 == 0) a2 -= a2 / 2, --t2;
  while (t1 < t2 && b2 % 2 == 0) b2 -= b2 / 2, --t2;
  if (a1 * b1 != a2 * b2) {
    puts("-1");
    return 0;
  }
  cout << ans << endl << a1 << ' ' << b1 << endl << a2 << ' ' << b2;
  return 0;
}
