import java.util.ArrayList;
import java.util.Scanner;

public class collatz {

	static int a;
	static int b;

	public static void main(String[] args) {
		ArrayList<Integer> listA = new ArrayList<Integer>();
		ArrayList<Integer> listB = new ArrayList<Integer>();

		Scanner sc = new Scanner(System.in);

		while (true) {
			a = sc.nextInt();
			b = sc.nextInt();
			int aZ = a;
			int bZ = b;

			if (a == 0 && b == 0) {
				break;
			}

			listB.add(b);

			while (b != 1) {
				if (b % 2 == 0) {
					b /= 2;
				} else {
					b = b * 3 + 1;
				}

				listB.add(b);
			}
			listB.add(1);

			int pozA = 0;
			int pozB = 0;
			boolean konec = false;

			while (a != 1) {
				
				for (int j = 0; j < listB.size(); j++) {
					if (a == listB.get(j)) {
						pozB = j;
						konec = true;
						break;
					}
				}

				if (konec) {
					break;
				}

				pozA++;
				
				if (a % 2 == 0) {
					a /= 2;
				} else {
					a = a * 3 + 1;
				}

			}

			System.out.println(aZ + " needs " + pozA + " steps, " + bZ
					+ " needs " + pozB + " steps, they meet at "
					+ listB.get(pozB));
		}
		
		System.exit(0);
	}

}
