import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;

public class collatz{

static int[] poleKroku= new int[100000000];
static int krok;

public static void main(String[] args) throws IOException{

BufferedReader r=new BufferedReader(new InputStreamReader(System.in));


while(true){
Arrays.fill(poleKroku, -1);
krok=0;
String s = r.readLine();
	if(s.equals("0 0")){
	break;
	}
int a=0;
int b=0;
StringTokenizer st= new StringTokenizer(s," ");
a = Integer.parseInt(st.nextToken());
b = Integer.parseInt(st.nextToken());
int cisloJedna = a;
int cisloDva = b;

poleKroku[a] = krok++;
	while(a!=1){
		if((a % 2) == 0 ){
		a=evenFill(a);
		} else {
		a=oddFill(a);
		}

	}
	krok = 0;
	while(true){
	if(-1 != poleKroku[b]){
	System.out.println(cisloJedna + " needs " + poleKroku[b] + " steps, " + cisloDva + " needs " + krok + " steps, they meet at " + b);
	break;
	}
	else{
	if((b % 2) == 0 ){
		b=even(b);
		} else {
		b=odd(b);
		}
		
	}

	}

}//while




}//main

public static int evenFill(int a){

a=a/2;
poleKroku[a] = krok++;

return a;
}

public static int oddFill(int a){

a=3*a + 1;
poleKroku[a] = krok++;
return a;
}

public static int even(int b){

b=b/2;
krok++;

return b;
}

public static int odd(int b){

b=3*b + 1;
krok++;
return b;
}


}//class

