#include <bits/stdc++.h>   using namespace std;   long long int gcd(long long int a, long long int b) {     return b == 0 ? a : gcd(b, a % b);   }   inline long long int lbt(long long int x) { return x & -x; }   inline void fail() {     cout <<  -1  << endl;     exit(0);   }   int main() {     long long int a, b, c, d, e, f, h, x(0);     cin >> a >> b >> c >> d;     e = a * b;     f = c * d;     h = gcd(e, f);     e /= h, f /= h;     if (e == 1) {       while (c % 3 == 0 && f != lbt(f)) ++x, c /= 3, c <<= 1, f /= 3, f <<= 1;       while (d % 3 == 0 && f != lbt(f)) ++x, d /= 3, d <<= 1, f /= 3, f <<= 1;       ;     } else if (f == 1) {       while (a % 3 == 0 && e != lbt(e)) ++x, a /= 3, a <<= 1, e /= 3, e <<= 1;       while (b % 3 == 0 && e != lbt(e)) ++x, b /= 3, b <<= 1, e /= 3, e <<= 1;       ;     } else if (e == lbt(e)) {       h = f;       while (h % 3 == 0) h /= 3;       if (h != 1) fail();       ;       while (c % 3 == 0 && f != lbt(f)) ++x, c /= 3, c <<= 1, f /= 3, f <<= 1;       while (d % 3 == 0 && f != lbt(f)) ++x, d /= 3, d <<= 1, f /= 3, f <<= 1;       ;     } else if (f == lbt(f)) {       h = e;       while (h % 3 == 0) h /= 3;       if (h != 1) fail();       ;       while (a % 3 == 0 && e != lbt(e)) ++x, a /= 3, a <<= 1, e /= 3, e <<= 1;       while (b % 3 == 0 && e != lbt(e)) ++x, b /= 3, b <<= 1, e /= 3, e <<= 1;       ;     } else       fail();     while ((~c & 1) && e < f) ++x, c >>= 1, f >>= 1;     while ((~d & 1) && e < f) ++x, d >>= 1, f >>= 1;     ;     while ((~a & 1) && f < e) ++x, a >>= 1, e >>= 1;     while ((~b & 1) && f < e) ++x, b >>= 1, e >>= 1;     ;   FINAL:     cout << x << endl << a <<     << b << endl << c <<     << d << endl;   }   