import static java.lang.Math.*;
import java.io.*;
import java.util.*;

public class collatz {

	void solve() throws Exception {
		
		long a = nextInt(), b = nextInt();
		while (a!=0 && b!=0) {
			
			long aorig = a, borig = b;
			
			LinkedList<Long> aa = new LinkedList<Long>();
			LinkedList<Long> bb = new LinkedList<Long>();
			HashSet<Long> aas = new HashSet<Long>();
			HashSet<Long> bbs = new HashSet<Long>();
			
			
			aa.add(a); bb.add(b); aas.add(a); bbs.add(b);
			
			while (true) {
				if ((a&1)==1) a=a*3+1L;
				else a>>=1L;
				
				aas.add(a); aa.add(a);
				if (a==1) break;
			}
			while (true) {
				if ((b&1)==1) b=b*3+1L;
				else b>>=1L;
				
				bbs.add(b); bb.add(b);
				if (b==1) break;
			}
			
//			debug(aa);
//			debug(bb);
			
			long bestnum=1;
			long astep=0, bstep=0;
			
			out: for (int i=0; i<aa.size(); ++i) {
				long x = aa.get(i);
				if (bbs.contains(x)) {
					for (int j=0; j<bb.size(); ++j) {
						long y = bb.get(j);
						if (y==x) {
							bestnum = y;
							astep = i; bstep = j;
							break out;
						}
					}
				}
			}
			
			
			println(String.format("%d needs %d steps, %d needs %d steps, they meet at %d", aorig,astep,borig,bstep,bestnum));
			
			a=nextInt(); b=nextInt();
		}
		
	}
	
	
	
	////////////////////////////////////////////////////////////////

	BufferedInputStream bis = new BufferedInputStream(System.in);
	
	String nextWord() throws IOException {
		StringBuilder sb = new StringBuilder();
		int ch = bis.read();
		while (ch<=' ') ch=bis.read();
		while (ch>' ') {
			sb.append((char)ch);
			ch=bis.read();
		}
		return new String(sb);
	}
	String nextLine() throws IOException {
		StringBuilder sb = new StringBuilder();
		int ch = bis.read();
		while (ch<=' ') ch=bis.read();
		while (ch!='\n' && ch!='\r') {
			sb.append((char)ch);
			ch=bis.read();
		}
		return new String(sb);
	}
	int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextWord());
	}
	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextWord());
	}
	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextWord());
	}
	
	void print(Object...o) {
		if (o==null) return;
		if (o.length==0) return;
		System.out.print(o[0]);
		for (int i=1; i<o.length; ++i) System.out.print(" "+o[i]);
	}
	void println(Object...o) {
		print(o);
		System.out.println();
	}
	
	String str(Object o) {
		return o.toString();
	}
	void debug(Object...o) {
		System.err.println(Arrays.deepToString(o));
	}
	
	public static void main(String[] args) throws Exception {
		new collatz().solve();
	}

}
