#include<iostream>
#include<map>

using namespace std;

int main()
{
	
	long A=0,B=0,x;
	int pocet=0; 
	int* mapa=new int[100000000];
	while(1)
	{
		
		for(int i=0;i<100000000;i++) mapa[i]=-1;

		A=1;B=1;
		cin>>A>>B;
		if(!((A==0)&&(B==0)))
		{
			x=A;
			pocet=1;
			mapa[x]=0;
			while(1)
			{
				if(x%2==0)
				{
					x=x/2;
					mapa[x]=pocet;
				}
				else
				{
					x=3*x+1;
					mapa[x]=pocet;
				}
				pocet++;
				if(x==1) break;
			}
			mapa[1]=pocet;
			x=B;
			pocet=0;
			if(mapa[x]!=-1)
			{
				cout<<A<<" needs "<<mapa[x]<<" steps, "<<B<<" needs "<<pocet<<" steps, they meet at "<<x<<endl;
				continue;
			}
			pocet++;
			while(1)
			{
				if(x%2==0)
				{
					x=x/2;
					if(mapa[x]!=-1)
					{
						cout<<A<<" needs "<<mapa[x]<<" steps, "<<B<<" needs "<<pocet<<" steps, they meet at "<<x<<endl;
						break;
					}
				}
				else
				{
					x=3*x+1;
					if(mapa[x]!=-1)
					{
						cout<<A<<" needs "<<mapa[x]<<" steps, "<<B<<" needs "<<pocet<<" steps, they meet at "<<x<<endl;
						break;
					}
				}
				pocet++;
			}
			
			fflush(stdin);
		}
		else
		{
			break;
			delete mapa;
		}
	}

	return 0;
}
