import java.util.HashSet;
import java.util.Scanner;


public class collatz {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		HashSet<Integer> bolo1; 
		HashSet<Integer> bolo2;
		
		int[] post1 = new int[500000];
		int[] post2 = new int[500000];
		
		int a,b;
		int c,d;
		
		int ps;
		int oi;
		
		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 HashSet<Integer>();
				bolo2 = new HashSet<Integer>();
				ps = 0;
				c = a;
				d = b;
				while (true) {
					bolo1.add(c);
					post1[ps] = c;
					bolo2.add(d);
					post2[ps++] = d;
					
					if (c % 2 == 0) c /= 2;
					else c = 3 * c + 1;
					if (bolo2.contains(c)) {
						oi = 0;
						while (post2[oi] != c) oi++;
						System.out.println(a + " needs " + ps + " steps, " + b + " needs " + oi + " steps, they meet at " + c);
						break;
					}
					
					if (d % 2 == 0) d /= 2;
					else d = 3 * d + 1;
					if (bolo1.contains(d)) {
						oi = 0;
						while (post1[oi] != d) oi++;
						System.out.println(a + " needs " + oi + " steps, " + b + " needs " + ps + " steps, they meet at " + d);
						break;
					}
				}
			}
		}
	}

}
