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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Contest08C {

	public static void solve() {
		long a1 = s.nextInt();
		long b1 = s.nextInt();
		long a2 = s.nextInt();
		long b2 = s.nextInt();
		HashMap<Integer, Integer> A1 = pf((int)a1);
		HashMap<Integer, Integer> A2 = pf((int)a2);
		HashMap<Integer, Integer> B1 = pf((int)b1);
		HashMap<Integer, Integer> B2 = pf((int)b2);
		boolean poss = Check(A1, B1, A2, B2);
		if(!poss) {
			out.println("-1");
			return;
		}
		int first2 = A1.containsKey(2) ? A1.get(2) : 0;
		first2 += B1.containsKey(2) ? B1.get(2) : 0;
		int first3 = B1.containsKey(3) ? B1.get(3) : 0;
		first3 += A1.containsKey(3) ? A1.get(3) : 0;
		int second2 = A2.containsKey(2) ? A2.get(2) : 0;
		second2 += B2.containsKey(2) ? B2.get(2) : 0;
		int second3 = A2.containsKey(3) ? A2.get(3) : 0;
		second3 += B2.containsKey(3) ? B2.get(3) : 0;
		int change = 0;
		int remove_12 = 0, remove_13 = 0, remove_22 = 0, remove_23 = 0;
		if(second3 > first3) {
			second2 += second3 - first3;
			change += second3 - first3;
			remove_23 = second3 - first3;
			for(int i = 0; i < remove_23; i++) {
				if(a2%3==0) {
					a2/=3L;
					a2*=2L;
				}else {
					b2/=3L;
					b2*=2L;
				}
			}
		}else {
			first2 += first3 - second3;
			change += first3 - second3;
			remove_13 = first3 - second3;
			for(int i = 0; i < remove_13; i++) {
				if(a1%3==0) {
					a1/=3L;
					a1*=2L;
				}else {
					b1/=3L;
					b1*=2L;
				}
			}
		}
		change += Math.abs(first2 - second2);
		if(first2 > second2) {
			remove_12 = first2 - second2;
		}else {
			remove_22 = second2 - first2;
		}
		while(remove_12 > 0) {
			if(a1%2 == 0) {
				a1/=2L;
			}else if(b1%2 == 0) {
				b1/=2L;
			}
			remove_12--;
		}
		while(remove_22 > 0) {
			if(a2%2 == 0) {
				a2/=2L;
			}else if(b2%2 == 0) {
				b2/=2L;
			}
			remove_22--;
		}
		out.println(change);
		out.println(a1+" "+b1);
		out.println(a2+" "+b2);
	}
	
	public static boolean Check(HashMap<Integer, Integer> a1, HashMap<Integer, Integer> b1, HashMap<Integer, Integer> a2, HashMap<Integer, Integer> b2) {
		HashMap<Integer, Integer> combinea = new HashMap<>();
		for(Integer x: a1.keySet()) {
			combinea.put(x, a1.get(x));
		}
		for(Integer x: b1.keySet()) {
			if(combinea.containsKey(x)) {
				combinea.put(x, combinea.get(x) + b1.get(x));
			}else {
				combinea.put(x, b1.get(x));
			}
		}
		HashMap<Integer, Integer> combineb = new HashMap<>();
		for(Integer x: a2.keySet()) {
			combineb.put(x, a2.get(x));
		}
		for(Integer x: b2.keySet()) {
			if(combineb.containsKey(x)) {
				combineb.put(x, combineb.get(x) + b2.get(x));
			}else {
				combineb.put(x, b2.get(x));
			}
		}
		for(Integer x: combinea.keySet()) {
			if(x == 2 || x==3) continue;
			if(!combineb.containsKey(x)) {
				return false;
			}
			if(combineb.get(x) != combinea.get(x)) {
				return false;
			}
		}
		for(Integer x: combineb.keySet()) {
			if(x == 2 || x == 3) continue;
			if(!combinea.containsKey(x)) {
				return false;
			}else if(combineb.get(x) != combinea.get(x)){
				return false;
			}
		}
		return true;
	}
	
	public static HashMap<Integer, Integer> pf(int number){
		HashMap<Integer, Integer> pf = new HashMap<>();
		for(int i = 2; i * i <= number; i++) {
			if(number%i == 0) {
				int count = 0;
				while(number%i == 0) {
					count++;
					number/=i;
				}
				pf.put(i, count);
			}
		}
		if(number != 1) {
			pf.put(number, 1);
		}
		return pf;
	}

	public static void main(String[] args) {
		out = new PrintWriter(new BufferedOutputStream(System.out));
		s = new FastReader();
		solve();
		out.close();
	}

	public static FastReader s;
	public static PrintWriter out;

	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	
}