#include <bits/stdc++.h>
using namespace std;
int max_time;
long long a1, b1, a2, b2;
vector<pair<int, long long> > aa1, bb1, aa2, bb2;
map<long long, int> bar_a, bar_b;
void div2(vector<pair<int, long long> > &pp, long long p, int times) {
  pp.push_back(make_pair(times++, p));
  while (p % 2 == 0) {
    p = p / 2;
    pp.push_back(make_pair(times++, p));
  }
}
void proceed(vector<pair<int, long long> > &pp, long long p, int times) {
  div2(pp, p, times++);
  while (p % 3 == 0) {
    p = p / 3 * 2;
    div2(pp, p, times++);
  }
}
void print(vector<pair<int, long long> > a) {
  for (int i = 0; i < a.size(); i++)
    cout << a[i].first << " " << a[i].second << endl;
  cout << endl;
}
int main() {
  cin >> a1 >> b1;
  cin >> a2 >> b2;
  proceed(aa1, a1, 0);
  proceed(bb1, b1, 0);
  proceed(aa2, a2, 0);
  proceed(bb2, b2, 0);
  long long s;
  for (int i = 0; i < aa2.size(); i++) {
    for (int j = 0; j < bb2.size(); j++) {
      s = aa2[i].second * bb2[j].second;
      if (bar_b[s] == 0 || bar_b[s] > aa2[i].first + bb2[j].first) {
        bar_b[s] = aa2[i].first + bb2[j].first;
      }
    }
  }
  int minimal_times = 100000000, times_a;
  long long ans_a1, ans_a2, ans_b1, ans_b2;
  for (int i = 0; i < aa1.size(); i++) {
    for (int j = 0; j < bb1.size(); j++) {
      s = aa1[i].second * bb1[j].second;
      if (bar_b.find(s) != bar_b.end()) {
        if (minimal_times > bar_b[s] + aa1[i].first + bb1[j].first) {
          minimal_times = bar_b[s] + aa1[i].first + bb1[j].first;
          ans_a1 = aa1[i].second;
          ans_b1 = bb1[j].second;
          times_a = aa1[i].first + bb1[j].first;
        }
      }
    }
  }
  if (minimal_times == 100000000) {
    puts("-1");
    return 0;
  }
  cout << minimal_times << endl;
  cout << ans_a1 << " " << ans_b1 << endl;
  for (int i = 0; i < aa2.size(); i++) {
    for (int j = 0; j < bb2.size(); j++) {
      if (aa2[i].second * bb2[j].second == ans_a1 * ans_b1 &&
          bar_b[ans_a1 * ans_b1] == aa2[i].first + bb2[j].first) {
        cout << aa2[i].second << " " << bb2[j].second << endl;
        return 0;
      }
    }
  }
  return 0;
}
