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.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
import java.lang.Long;

public class Test {
	static long mod = 1000000007;
	static double[][] dp;
	static int contains;

	public static void main(String[] args) throws FileNotFoundException {
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		long[][] s = new long[2][2];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				s[i][j] = in.nextInt();
			}
		}

		int[][][] c = new int[2][2][2];
		for (int j = 0; j < 2; j++)
			for (int i = 0; i < 2; i++) {
				while (s[j][i] % 2 == 0) {
					c[j][i][0]++;
					s[j][i] /= 2;
				}
				while (s[j][i] % 3 == 0) {
					c[j][i][1]++;

					s[j][i] /= 3;
				}
			}

		long x = s[0][0] * s[0][1];
		long y = s[1][0] * s[1][1];
		if (x != y) {
			out.println(-1);
		} else {
			int th = Math.min(c[0][0][1] + c[0][1][1], c[1][0][1] + c[1][1][1]);
			int min = Integer.MAX_VALUE;
			int t = 0;
			for (int i = 0; i <= th; i++) {
				int a = 0, b = 0;
				if (c[0][0][1] + c[0][1][1] > i) {
					a = c[0][0][1] + c[0][1][1] - i;
				}
				if (c[1][0][1] + c[1][1][1] > i) {
					b = c[1][0][1] + c[1][1][1] - i;
				}
				int total = Math.min(c[0][0][0] + c[0][1][0] + a, c[1][0][0]
						+ c[1][1][0] + b);
				int v = a
						+ b
						+ Math.max(c[0][0][0] + c[0][1][0] + a, c[1][0][0]
								+ c[1][1][0] + b) - total;
				if (v < min) {
					min = v;
					t = i;
				}
			}
			out.println(min);

			if (c[0][0][1] + c[0][1][1] > t) {
				int a = c[0][0][1] + c[0][1][1] - t;
				int v = Math.min(a, c[0][0][1]);
				a -= v;
				c[0][0][1] -= v;
				c[0][0][0] += v;
				v = Math.min(a, c[0][1][1]);
				a -= v;
				c[0][1][1] -= v;
				c[0][1][0] += v;

			}

			if (c[1][0][1] + c[1][1][1] > t) {
				int a = c[1][0][1] + c[1][1][1] - t;
				int v = Math.min(a, c[1][0][1]);
				a -= v;
				c[1][0][1] -= v;
				c[1][0][0] += v;
				v = Math.min(a, c[1][1][1]);
				a -= v;
				c[1][1][1] -= v;
				c[1][1][0] += v;
			}
			int t1 = Math.min(c[0][0][0] + c[0][1][0], c[1][0][0] + c[1][1][0]);
			if (c[0][0][0] + c[0][1][0] > t1) {
				int a = c[0][0][0] + c[0][1][0] - t1;
				int v = Math.min(a, c[0][0][0]);
				a -= v;
				c[0][0][0] -= v;
				
				v = Math.min(a, c[0][1][0]);
				a -= v;
				c[0][1][0] -= v;
				

			}

			if (c[1][0][0] + c[1][1][0] > t1) {
				int a = c[1][0][0] + c[1][1][0] - t1;
				int v = Math.min(a, c[1][0][0]);
				a -= v;
				c[1][0][0] -= v;
				
				v = Math.min(a, c[1][1][0]);
				a -= v;
				c[1][1][0] -= v;
				
			}
			out.println((long) (Math.pow(2, c[0][0][0])
					* Math.pow(3, c[0][0][1]) * s[0][0])
					+ " "
					+ (long) (Math.pow(2, c[0][1][0]) * Math.pow(3, c[0][1][1]) * s[0][1]));
			out.println((long) (Math.pow(2, c[1][0][0])
					* Math.pow(3, c[1][0][1]) * s[1][0])
					+ " "
					+ (long) (Math.pow(2, c[1][1][0]) * Math.pow(3, c[1][1][1]) * s[1][1]));

		}

		out.close();
	}

	static double[] cal(int p) {
		if (p == 1) {
			return new double[] { 1, 0 };
		} else if (p == 0) {
			return new double[] { 0, 1 };
		} else if (p == 2) {
			return new double[] { 1, 1 };
		} else {
			if (dp[p][0] != -1.0) {
				return dp[p];
			}

			double[] d = cal(p - 2);
			double[] result = new double[2];
			result[0] = d[1] + d[0];
			result[1] = d[1];
			result[0] += d[0];
			result[1] += d[0];
			return dp[p] = result;
		}
	}

	static class Name implements Comparable<Name> {
		String name;
		int h;

		public Name(String name, int h) {
			super();
			this.name = name;
			this.h = h;
		}

		public int compareTo(Name o) {

			return h - o.h;
		}

	}

	static int find(int index, int[] u) {
		if (u[index] != index) {
			return u[index] = find(u[index], u);
		}
		return index;
	}

	static int crossProduct(Point a, Point b) {
		return a.x * b.y + a.y * b.x;
	}

	static long squareDist(Point a) {
		long x = a.x;
		long y = a.y;
		return x * x + y * y;
	}

	static Point minus(Point a, Point b) {
		return new Point(a.x - b.x, a.y - b.y);
	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	static class Point {
		int x, y;

		public Point(int x, int y) {
			super();
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return "{" + x + " " + y + "}";
		}

	}

	static class Entry implements Comparable<Entry> {
		int x, cost;

		public Entry(int x, int cost) {
			super();
			this.x = x;
			this.cost = cost;
		}

		public int compareTo(Entry o) {
			// TODO Auto-generated method stub
			if (cost > o.cost) {
				return 1;
			} else if (cost == o.cost) {
				return -1;
			}

			return 0;
		}
	}

	static int gcd(int a, int b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("B-large.in"))));
		}

		public String next() {

			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					throw new RuntimeException();
				}
			}
			return st.nextToken();
		}

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

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

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

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}