public class collatz {

    private static int a, b;
    
    public static void main(String[] args) {
        java.util.Scanner s = new java.util.Scanner(System.in);
        while (true) {
            int counter = 1;
            int as = s.nextInt();
            int bs = s.nextInt();
            boolean aend = false;
            boolean bend = false;
            a = as;
            b = bs;
            if (a == 0 && b == 0)
                break;
            int[] mapA = new int[10000000];
            int[] mapB = new int[10000000];
            int h = 1;
            while (h == 1) {
                if (!aend) {
                    mapA[a] = counter;
                    if (a % 2 == 0)
                        a /= 2;
                    else
                        a = 3 * a + 1;
                }
                if (a == 1)
                    aend = true;
                
                if (!bend) {
                    mapB[b] = counter;
                    if (b % 2 == 0)
                        b /= 2;
                    else
                        b = 3 * b + 1;
                }
                if (b == 1)
                    bend = true;
                
                if (mapA[b] != 0) {
                    System.out.format("%d needs %d steps, %d needs %d steps, they meet at %d\n", as, mapA[b] - 1, bs, counter, b);
                    break;
                } else if (mapB[a] != 0) {
                    System.out.format("%d needs %d steps, %d needs %d steps, they meet at %d\n", as, counter, bs, mapB[a] - 1, a);
                    break;
                }
                
                ++counter;
            }
        }
    }

}
