#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e6 + 5;
int num1[MAXN], num2[MAXN];
long long big1 = -1, big2 = -1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long a1, b1, a2, b2;
  cin >> a1 >> b1 >> a2 >> b2;
  long long k1 = a1 * b1;
  long long k2 = a2 * b2;
  for (long long i = 2; i < MAXN; i++)
    if (k1 % i != 0)
      continue;
    else
      while (k1 != 0 && k1 % i == 0) {
        num1[i]++;
        k1 /= i;
      }
  if (k1 != 1) {
    big1 = k1;
    if (big1 < MAXN) num1[big1]++, big1 = -1;
  }
  for (long long i = 2; i < MAXN; i++)
    if (k2 % i != 0)
      continue;
    else
      while (k2 != 0 && k2 % i == 0) {
        num2[i]++;
        k2 /= i;
      }
  if (k2 != 1) {
    big2 = k2;
    if (big2 < MAXN) num2[big2]++, big2 = -1;
  }
  for (int i = 4; i < MAXN; i++)
    if (num1[i] != num2[i] || big1 != big2) return cout << "-1\n", 0;
  int move3 = 0, move2 = 0;
  bool v3 = true, v2 = true;
  move3 += abs(num1[3] - num2[3]);
  if (num1[3] > num2[3]) num1[2] += move3;
  if (num1[3] < num2[3]) num2[2] += move3, v3 = false;
  move2 += abs(num1[2] - num2[2]);
  if (num1[2] < num2[2]) v2 = false;
  cout << move3 + move2 << "\n";
  for (int i = 0; i < move3; i++)
    if (!v3) {
      if (a2 % 3)
        b2 /= 3, b2 *= 2;
      else
        a2 /= 3, a2 *= 2;
    } else {
      if (a1 % 3)
        b1 /= 3, b1 *= 2;
      else
        a1 /= 3, a1 *= 2;
    }
  for (int i = 0; i < move2; i++)
    if (!v2) {
      if (a2 % 2)
        b2 /= 2;
      else
        a2 /= 2;
    } else {
      if (a1 % 2)
        b1 /= 2;
      else
        a1 /= 2;
    }
  cout << a1 << " " << b1 << "\n" << a2 << " " << b2 << "\n";
}
