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+1;
				else a>>=1;
				
				if (aas.contains(a)) break;
				aas.add(a); aa.add(a);
			}
			while (true) {
				if ((b&1)==1) b=b*3+1;
				else b>>=1;
				
				if (bbs.contains(b)) break;
				bbs.add(b); bb.add(b);
			}
			
//			debug(aa);
//			debug(bb);
			
			int best = Integer.MAX_VALUE;
			long bestnum=0;
			int astep=0, bstep=0;
			
			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) if (min(i,j)<best) {
							bestnum = y;
							best = (int)min(i,j);
							astep = i; bstep = j;
						}
					}
				}
			}
			for (int i=0; i<bb.size(); ++i) {
				long x = bb.get(i);
				if (aas.contains(x)) {
					for (int j=0; j<aa.size(); ++j) {
						long y = aa.get(j);
						if (y==x) if (min(i,j)<best) {
							bestnum = y;
							best = (int)min(i,j);
							astep = j; bstep = i;
						}
					}
				}
			}
			
			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();
	}

}
