import java.util.HashMap;
import java.util.Hashtable;
import java.util.Scanner;

public class collatz {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if (a == 0 && b == 0) {
				break;
			}
			
			HashMap<Long, Long> map = new HashMap<Long, Long>();
			
			long newA = a;
			long newB = b;
			
			long steps = 0;
			long res = 0;
			long stepsA = 0;
			long stepsB = 0;
			
			boolean aDone = false;
			boolean bDone = false;
			
			while (true) {
				
				if (!aDone) {
					if (map.containsKey(newA)) {
						res = newA;
						stepsA = steps;
						stepsB = map.get(newA);
						break;
					}
					
					
					map.put(newA, steps);
					
					if (newA == 1) {
						aDone = true;
					}
				}
				
				if (!bDone) {
					if (map.containsKey(newB)) {
						res = newB;
						stepsA = map.get(newB);
						stepsB = steps;
						break;
					}
					
					map.put(newB, steps);
					if (newB == 1) {
						bDone = true;
					}
				}
				
				steps++;
				
				// calc next!
				
				if (newA % 2 == 0) {
					newA = newA / 2;
				} else {
					newA = newA * 3 + 1;
				}
				
				if (newB % 2 == 0) {
					newB = newB / 2;
				} else {
					newB = newB * 3 + 1;
				}
			}
			
			System.out.printf("%d needs %d steps, %d needs %d steps, they meet at %d", 
					a, stepsA, b, stepsB, res );
			System.out.println();
		}
	}
}
