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.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.PriorityQueue;
import java.util.Map.Entry;

public class D {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	
	class Trio {
		int cnt;
		long a;
		long b;

		Trio(int cnt, long a, long b) {
			this.cnt = cnt;
			this.a = a;
			this.b = b;
		}
	}
	
	class State implements Comparable<State> {
		long val;
		int cnt;

		State(long val, int cnt) {
			this.val = val;
			this.cnt = cnt;
		}

		public int compareTo(State s) {
			return cnt - s.cnt;
		}
	}
	
	public void run() {
		long a1 = in.nextInt(), b1 = in.nextInt();
		long a2 = in.nextInt(), b2 = in.nextInt();
		
		long[] sizes = {a1, b1, a2, b2};
		
		int[][] cnt = new int[4][2];
		
		for (int i = 0; i < 4; i++) {
			for (int j = 2; j <= 3; j++) {
				while (sizes[i] % j == 0) {
					sizes[i] /= j;
					cnt[i][j-2]++;
				}
			}
		}
		
		if (sizes[0] * sizes[1] != sizes[2] * sizes[3]) {
			System.out.println("-1");
			return;
		}
		sizes = new long[]{a1, b1, a2, b2};
		
		HashMap<Long, Integer>[] maps = new HashMap[4];
		PriorityQueue<State> pq = new PriorityQueue<State>();
		for (int i = 0; i < 4; i++) {
			maps[i] = new HashMap<Long, Integer>();
			pq.clear();
			pq.add(new State(sizes[i], 0));
			
			while (!pq.isEmpty()) {
				State s = pq.poll();
				if (!maps[i].containsKey(s.val)) {
					maps[i].put(s.val, s.cnt);
				
					if (s.val % 3 == 0)
						pq.add(new State((2 * s.val) / 3, s.cnt + 1));
					if (s.val % 2 == 0)
						pq.add(new State(s.val / 2, s.cnt + 1));
				}
			}
		}
		
		
		HashMap<Long, Trio> hash = new HashMap<Long, Trio>();
		for (Entry<Long, Integer> e1 : maps[0].entrySet()) for (Entry<Long, Integer> e2 : maps[1].entrySet()) { 	
			long val1 = e1.getKey() * e2.getKey();
			int num1 = e1.getValue() + e2.getValue();
			
			int temp = Integer.MAX_VALUE;
			if (hash.containsKey(val1)) temp = hash.get(val1).cnt;
			
			if (temp > num1)
				hash.put(val1, new Trio(num1, e1.getKey(), e2.getKey()));
		}
		
		long res = Integer.MAX_VALUE;
		long[] ans = new long[4];

		for (Entry<Long, Integer> e3 : maps[2].entrySet()) for (Entry<Long, Integer> e4 : maps[3].entrySet()) {					
			long val2 = e3.getKey() * e4.getKey(), num2 = e3.getValue() + e4.getValue();
			if (hash.containsKey(val2) && hash.get(val2).cnt + num2 < res) {
				Trio t = hash.get(val2);
				res = t.cnt + num2;
				ans[0] = t.a;
				ans[1] = t.b;
				ans[2] = e3.getKey();
				ans[3] = e4.getKey();
			}
		}
		
		System.out.println(res);
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				System.out.print(ans[i*2+j] + " ");
			}
			System.out.println();
		}		
		out.close();
	}

	public static void main(String[] args) {
		new D().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] nextIntArray(int n) {
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
				array[i] = nextInt();

			return array;
		}

		int[][] nextIntMap(int n, int m) {
			int[][] map = new int[n][m];
			for (int i = 0; i < n; i++) {
				map[i] = in.nextIntArray(m);
			}
			return map;
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		long[] nextLongArray(int n) {
			long[] array = new long[n];
			for (int i = 0; i < n; i++)
				array[i] = nextLong();

			return array;
		}

		long[][] nextLongMap(int n, int m) {
			long[][] map = new long[n][m];
			for (int i = 0; i < n; i++) {
				map[i] = in.nextLongArray(m);
			}
			return map;
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();

			return array;
		}

		double[][] nextDoubleMap(int n, int m) {
			double[][] map = new double[n][m];
			for (int i = 0; i < n; i++) {
				map[i] = in.nextDoubleArray(m);
			}
			return map;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}