import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;


public class collatz {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		TreeSet<Integer> bolo1; 
		TreeSet<Integer> bolo2;
		
		ArrayList<Integer> post1;
		ArrayList<Integer> post2;
		
		int a,b;
		int c,d;
		
		while ((a = sc.nextInt()) != 0 && (b = sc.nextInt()) != 0) {
			if (a == b) {
				System.out.println(a + " needs 0 steps, " + b + " needs 0 steps, they meet at " + a);
			} else {
				bolo1 = new TreeSet<Integer>();
				bolo2 = new TreeSet<Integer>();
				post1 = new ArrayList<Integer>();
				post2 = new ArrayList<Integer>();
				c = a;
				d = b;
				while (true) {
					bolo1.add(c);
					post1.add(c);
					bolo2.add(d);
					post2.add(d);
					
					if (c % 2 == 0) c /= 2;
					else c = 3 * c + 1;
					if (bolo2.contains(c)) {
						System.out.println(a + " needs " + post1.size() + " steps, " + b + " needs " + post2.indexOf(c) + " steps, they meet at " + c);
						break;
					}
					
					if (d % 2 == 0) d /= 2;
					else d = 3 * d + 1;
					if (bolo1.contains(d)) {
						System.out.println(a + " needs " + post1.indexOf(d) + " steps, " + b + " needs " + post2.size() + " steps, they meet at " + d);
						break;
					}
				}
			}
		}
	}

}
