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.InputStreamReader;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.StringTokenizer;


public class con279_D {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tok = new StringTokenizer( br.readLine() );
		int a1 = Integer.parseInt( tok.nextToken() );
		int b1 = Integer.parseInt( tok.nextToken() );

		tok = new StringTokenizer( br.readLine() );
		int a2 = Integer.parseInt( tok.nextToken() );
		int b2 = Integer.parseInt( tok.nextToken() );

		Result res = solve(a1, a2, b1, b2 );
		System.out.println(res.time);
		if ( res.time >= 0 ) {
			System.out.printf( "%d %d\n%d %d\n", res.a1, res.b1, res.a2, res.b2 );
		}
	}

	static HashSet<String> cache = new HashSet<>();
	
	static Result solve(int a1, int a2, int b1, int b2) {
		cache.clear();
		Result res = new Result();
		res.time = -1;
		
		if ( isPossible(a1, a2, b1, b2) == false ) {
			return res;
		}
		
		int maxq = 0;
		LinkedList<State> pq = new LinkedList<>();
		add( pq, new State(0, a1, a2, b1, b2));
		while ( pq.isEmpty() == false ) {
			State act = pq.poll();
			if ( isOk(act) ) {
				res.time = act.cost;
				res.a1 = act.a1;
				res.b1 = act.b1;
				res.a2 = act.a2;
				res.b2 = act.b2;
				return res;
			}
			
			long s1 = act.size1();
			long s2 = act.size2();
			State copy;
			if ( s1 > s2 ) {
				if ( (act.a1 & 1) == 0 ) {
					copy = act.copy();
					copy.cost++;
					copy.a1 >>= 1;
//					add(pg, copy);
					add(pq, copy);
				}
				if ( act.a1 % 3 == 0 ) {
					copy = act.copy();
					copy.cost++;
					copy.a1 = (copy.a1 / 3) << 1;
					add(pq, copy);
				}
				if ( (act.b1 & 1) == 0 ) {
					copy = act.copy();
					copy.cost++;
					copy.b1 >>= 1;
					add(pq, copy);
					
				}
				if ( act.b1 % 3 == 0 ) {
					copy = act.copy();
					copy.cost++;
					copy.b1 = (copy.b1 / 3) << 1;
					add(pq, copy);
				}
			} else {
				if ( (act.a2 & 1) == 0 ) {
					copy = act.copy();
					copy.cost++;
					copy.a2 >>= 1;
					add(pq, copy);
				}
				if ( act.a2 % 3 == 0 ) {
					copy = act.copy();
					copy.cost++;
					copy.a2 = (copy.a2 / 3) << 1;
					add(pq, copy);
				}
				if ( (act.b2 & 1) == 0 ) {
					copy = act.copy();
					copy.cost++;
					copy.b2 >>= 1;
					add(pq, copy);
				}
				if ( act.b2 % 3 == 0 ) {
					copy = act.copy();
					copy.cost++;
					copy.b2 = (copy.b2 / 3) << 1;
					add(pq, copy);
				}
			}
			if ( pq.size() > maxq ) {
				maxq = pq.size();
//				System.out.println(maxq);
			}
		}
		
		return res;
	}

	private static boolean isPossible(int a1, int a2, int b1, int b2) {
		int na1 = reduce(a1);
		int nb1 = reduce(b1);
		int na2 = reduce(a2);
		int nb2 = reduce(b2);
		long s1 = na1;
		s1 *= nb1;
		long s2 = na2;
		s2 *= nb2;
		return s1 == s2;
	}

	private static int reduce(int n) {
		while ( (n & 1) == 0 ) {
			n >>= 1;
		}
		while ( n % 3 == 0 ) {
			n /= 3;
		}
		return n;
	}

	private static void add(LinkedList<State> pq, State s) {
		String k = s.toKey();
		if (cache.contains(k)) {
			// do nothing
		} else {
			cache.add(k);
			pq.add(s);
		}
	}

	private static boolean isOk(State s) {
//		long s1 = 1;
//		s1 *= s.a1;
//		s1 *= s.b1;
//		long s2 = 1;
//		s2 *= s.a2;
//		s2 *= s.b2;
		long s1 = s.size1();
		long s2 = s.size2();
		return s1 == s2;
	}

	static class State {
		int cost;
		int a1, a2, b1, b2;

		public State() {
		}

		public State copy() {
			return new State(cost, a1, a2, b1, b2);
		}

		public long size2() {
			long s = a2;
//			s *= a2;
			s *= b2;
			return s;
		}

		public long size1() {
			long s = a1;
//			s *= a1;
			s *= b1;
			return s;
		}

		public State(int cost, int a1, int a2, int b1, int b2) {
			this.cost = cost;
			this.a1 = a1;
			this.a2 = a2;
			this.b1 = b1;
			this.b2 = b2;
		}

//		public String toString() {
//			long s1 = 1;
//			s1 *= a1;
//			s1 *= b1;
//			long s2 = 1;
//			s2 *= a2;
//			s2 *= b2;
//			return String.format( "%dx%d (%d) ~ %dx%d (%d) [%d]", a1, b1, s1, a2, b2, s2, cost);			
//		};
		
		public String toKey() {
			int min1 = Math.min( a1, b1 );
			int max1 = Math.max( a1, b1 );

			int min2 = Math.min( a2, b2 );
			int max2 = Math.max( a2, b2 );
			
//			return String.format( "%dx%d~%dx%d", min1, max1, min2, max2);
			StringBuilder sb = new StringBuilder();
			sb.append(min1).append('x').append(max1).append('~');
			sb.append(min2).append('x').append(max2);
			return sb.toString();
		}

	}
	
	static class Result {
		int time;
		int a1, a2, b1, b2;
	}

}