Problem: Polycarpus likes giving presents to Paraskevi. He has bought two chocolate bars, each of them has the shape of a segmented rectangle. The first bar is a1 × b1 segments large and the second one is a2 × b2 segments large.

Polycarpus wants to give Paraskevi one of the bars at the lunch break and eat the other one himself. Besides, he wants to show that Polycarpus's mind and Paraskevi's beauty are equally matched, so the two bars must have the same number of squares.

To make the bars have the same number of squares, Polycarpus eats a little piece of chocolate each minute. Each minute he does the following:

  * he either breaks one bar exactly in half (vertically or horizontally) and eats exactly a half of the bar, 
  * or he chips of exactly one third of a bar (vertically or horizontally) and eats exactly a third of the bar. 



In the first case he is left with a half, of the bar and in the second case he is left with two thirds of the bar.

Both variants aren't always possible, and sometimes Polycarpus cannot chip off a half nor a third. For example, if the bar is 16 × 23, then Polycarpus can chip off a half, but not a third. If the bar is 20 × 18, then Polycarpus can chip off both a half and a third. If the bar is 5 × 7, then Polycarpus cannot chip off a half nor a third.

What is the minimum number of minutes Polycarpus needs to make two bars consist of the same number of squares? Find not only the required minimum number of minutes, but also the possible sizes of the bars after the process.

Input

The first line of the input contains integers a1, b1 (1 ≤ a1, b1 ≤ 109) — the initial sizes of the first chocolate bar. The second line of the input contains integers a2, b2 (1 ≤ a2, b2 ≤ 109) — the initial sizes of the second bar.

You can use the data of type int64 (in Pascal), long long (in С++), long (in Java) to process large integers (exceeding 231 - 1).

Output

In the first line print m — the sought minimum number of minutes. In the second and third line print the possible sizes of the bars after they are leveled in m minutes. Print the sizes using the format identical to the input format. Print the sizes (the numbers in the printed pairs) in any order. The second line must correspond to the first bar and the third line must correspond to the second bar. If there are multiple solutions, print any of them.

If there is no solution, print a single line with integer -1.

Examples

Input

2 6
2 3


Output

1
1 6
2 3


Input

36 5
10 16


Output

3
16 5
5 16


Input

3 5
2 1


Output

-1

Solution (in JAVA):

Solution:

import java.io.*;

public class Main {
    private final Reader reader;

    private final Writer writer;

    public static void main(String[] args) throws IOException {
        new Main().solve();

    }
    private void solve() throws IOException {
        long a[] = new long[2];
        long b[] = new long[2];
        a[0] = reader.nextInt();
        b[0] = reader.nextInt();
        a[1] = reader.nextInt();
        b[1] = reader.nextInt();

        int factors_a[][] = new int[2][2]; //[a1,2][2,3]
        int factors_b[][] = new int[2][2]; //[b1,2][2,3]

        factors_a[0][0] = factors(a[0], 2);
        factors_a[0][1] = factors(a[0], 3);
        factors_a[1][0] = factors(a[1], 2);
        factors_a[1][1] = factors(a[1], 3);

        factors_b[0][0] = factors(b[0], 2);
        factors_b[0][1] = factors(b[0], 3);
        factors_b[1][0] = factors(b[1], 2);
        factors_b[1][1] = factors(b[1], 3);

        a[0] = div(a[0], factors_a[0]);
        a[1] = div(a[1], factors_a[1]);
        b[0] = div(b[0], factors_b[0]);
        b[1] = div(b[1], factors_b[1]);

        if (a[0] * b[0] != a[1] * b[1]) {
            writer.print("-1\n");
            writer.flush();
            return;
        }

        int threes[] = new int[2];
        threes[0] = factors_a[0][1] + factors_b[0][1];
        threes[1] = factors_a[1][1] + factors_b[1][1];
        int twos[] = new int[2];
        twos[0] = factors_a[0][0] + factors_b[0][0];
        twos[1] = factors_a[1][0] + factors_b[1][0];

        int minutes = 0;
        if (threes[0] < threes[1]) {
            twos[1] += (threes[1] - threes[0]);
            minutes += (threes[1] - threes[0]);
            for (int i = 0; i < minutes; i++) {
                if (factors_a[1][1] > 0) {
                    factors_a[1][1]--;
                    factors_a[1][0]++;
                } else if (factors_b[1][1] > 0) {
                    factors_b[1][1]--;
                    factors_b[1][0]++;
                } else {
                    throw new RuntimeException();
                }
            }
        } else {
            minutes += (threes[0] - threes[1]);
            for (int i = 0; i < minutes; i++) {
                if (factors_a[0][1] > 0) {
                    factors_a[0][1]--;
                    factors_a[0][0]++;
                } else if (factors_b[0][1] > 0) {
                    factors_b[0][1]--;
                    factors_b[0][0]++;
                } else {
                    throw new RuntimeException();
                }
            }
        }

        if (factors_a[0][0] + factors_b[0][0] > factors_a[1][0] + factors_b[1][0]) {
            int diff = factors_a[0][0] + factors_b[0][0] - factors_a[1][0] - factors_b[1][0];
            minutes += diff;
            for (int i = 0; i < diff; i++) {
                if (factors_a[0][0] > 0) {
                    factors_a[0][0]--;
                } else if (factors_b[0][0] > 0) {
                    factors_b[0][0]--;
                } else {
                    throw new RuntimeException();
                }
            }
        } else {
            int diff = factors_a[1][0] + factors_b[1][0] - factors_a[0][0] - factors_b[0][0];
            minutes += diff;
            for (int i = 0; i < diff; i++) {
                if (factors_a[1][0] > 0) {
                    factors_a[1][0]--;
                } else if (factors_b[1][0] > 0) {
                    factors_b[1][0]--;
                } else {
                    throw new RuntimeException();
                }
            }
        }

        writer.print(minutes + "\n");

        a[0] = mul(a[0], factors_a[0]);
        b[0] = mul(b[0], factors_b[0]);
        a[1] = mul(a[1], factors_a[1]);
        b[1] = mul(b[1], factors_b[1]);

        writer.print(a[0] + " " + b[0] + "\n");
        writer.print(a[1] + " " + b[1] + "\n");
        writer.flush();
    }

    private long mul(long num, int[] fact) {
        for (int i = 0; i < fact[0]; i++) {
            num *= 2L;
        }
        for (int i = 0; i < fact[1]; i++) {
            num *= 3L;
        }
        return num;
    }

    private long div(long num, int[] fact) {
        for (int i = 0; i < fact[0]; i++) {
            num /= 2L;
        }
        for (int i = 0; i < fact[1]; i++) {
            num /= 3L;
        }
        return num;
    }

    private int factors(long num, int f) {
        int cnt = 0;
        while (num % f == 0) {
            num /= f;
            cnt++;
        }
        return cnt;
    }


    Main(InputStream in, OutputStream out) {
        this.reader = new Reader(in);
        this.writer = new Writer(out);
    }

    public Main() {
        this.reader = new Reader();
        this.writer = new Writer();
    }


}

class Reader {

    private final int BUFFER_SIZE = 65536;

    private final DataInputStream din;

    private final byte[] buffer;

    private int bufferPointer, bytesRead;

    Reader() {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(InputStream in) {
        din = new DataInputStream(in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public long nextUnsignedLong() throws IOException {
        long ret = 0;
        byte c = read();
        while (c <= 32) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0');
        return ret;
    }

    public int nextUnsignedInt() throws IOException {
        int ret = 0;
        byte c = read();
        while (c <= 32) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0');
        return ret;
    }

    public int nextInt() throws IOException {
        int ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) {
            c = read();
        }
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0');
        if (neg) {
            return -ret;
        }
        return ret;
    }

    public String nextString(int MAX) throws IOException {
        int cnt = 0;
        char[] buf = new char[MAX];
        byte c;
        while ((c = read()) < 33) ;
        buf[cnt++] = (char) c;
        while ((c = read()) >= 33) {
            buf[cnt++] = (char) c;
        }
        return new String(buf, 0, cnt);
    }

    public char firstCharOfNextUnSpacedString() throws IOException {
        byte c;
        char res;
        while ((c = read()) < 33) ;
        res = (char) c;
        while ((c = read()) >= 33) ;
        return res;
    }

    private void fillBuffer() throws IOException {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) {
            buffer[0] = -1;
        }
    }

    private byte read() throws IOException {
        if (bufferPointer == bytesRead) {
            fillBuffer();
        }
        return buffer[bufferPointer++];
    }
}

class Writer {
    private final BufferedWriter out;

    Writer() {
        out = new BufferedWriter(new OutputStreamWriter(System.out), 512);
    }

    public Writer(OutputStream out) {
        this.out = new BufferedWriter(new OutputStreamWriter(out), 512);
    }

    void print(char c) throws IOException {
        out.write(c);
    }

    void print(String str) throws IOException {
        out.write(str);
    }

    void println() throws IOException {
        out.write("\n");
    }

    void flush() throws IOException {
        out.flush();
    }

    @Override
    protected void finalize() throws IOException {
        out.flush();
    }
}