import java.util.*;

public class collatz
{
    public class myC
    {
	public int a;
	public int b;
	public myC(int a, int b)
	{
	    this.a = a;
	    this.b = b;
	}
    }
    public static void main(String[] args)
    {
	collatz t = new collatz();
	t.test();
	
    }
    public void test()
    {
	Scanner sc = new Scanner(System.in);
	int m,n;
	m = sc.nextInt();
	n = sc.nextInt();
	while(m!=0||n!=0)
	{
	    Hashtable<Integer, myC> map = new Hashtable<Integer, myC>();
	    map.put(m,new myC(0,m));
	    map.put(n,new myC(0,n));
	    if(m == n)
	    {
		System.out.println(m+" needs 0 steps, "+n+" needs 0 steps, they meet at "+n);
	    }else
	    {
		boolean pom = true, pomm = true, pomn = true;
		int mm = m;
		int nn = n;
		int krok = 0;
		do
		{
		    krok++;
		    if(pomm)
		    if(mm%2 == 0)
		    {
			mm = mm/2;
			if(map.get(mm) == null)
			{
			    map.put(mm,new myC(krok,m));
			} else
			{
			    if (map.get(mm).b != m)
			    {
				System.out.println(m+" needs "+krok+" steps, "+n+" needs "+map.get(mm).a+" steps, they meet at "+mm);
				pom = false;
				break;
			    } else pomm=false;
			}
		    } else
		    {
			mm = 3*mm+1;
			if(map.get(mm) == null)
			{
			    map.put(mm,new myC(krok,m));
			} else
			{
			    if (map.get(mm).b != m)
			    {
				System.out.println(m+" needs "+krok+" steps, "+n+" needs "+map.get(mm).a+" steps, they meet at "+mm);
				pom = false;
				break;
			    }else pomm=false;
			}
		    }
		    if(pomn)
		    if(nn%2 == 0)
		    {
			nn = nn/2;
			if(map.get(nn) == null)
			{
			    map.put(nn,new myC(krok,n));
			} else
			{
			    if (map.get(nn).b != n)
			    {
				System.out.println(m+" needs "+krok+" steps, "+n+" needs "+map.get(mm).a+" steps, they meet at "+mm);
				pom = false;
				break;
			    }else pomn=false;
			}
		    } else
		    {
			nn = 3*nn+1;
			if(map.get(nn) == null)
			{
			    map.put(nn,new myC(krok,n));
			} else
			{
			    if (map.get(nn).b != n)
			    {
				System.out.println(m+" needs "+krok+" steps, "+n+" needs "+map.get(mm).a+" steps, they meet at "+mm);
				pom = false;
				break;
			    }else pomn=false;
			}
		    }
		}while(pom);
	    }
	    
	    m = sc.nextInt();
	    n = sc.nextInt();
	}
    }
}