#include<iostream>
#include<map>

using namespace std;

int main()
{
	
	long A=0,B=0,x,y;
	int pocet=0; 
	while(1)
	{
		map<long,int> mapa1;
		map<long,int> mapa2;
		A=1;B=1;
		cin>>A>>B;
		if(!((A==0)&&(B==0)))
		{
			x=A;
			y=B;
			pocet=1;
			mapa1[x]=0;
			mapa2[y]=0;
			while(1)
			{
				if(x%2==0)
				{
					x=x/2;
					mapa1[x]=pocet;

					if(mapa2.find(x)!=mapa2.end())
					{
						cout<<A<<" needs "<<mapa1[x]<<" steps, "<<B<<" needs "<<mapa2[x]<<" steps, they meet at "<<x<<endl;
						break;
					}
				}
				else
				{
					x=3*x+1;
					mapa1[x]=pocet;
					if(mapa2.find(x)!=mapa2.end())
					{
						cout<<A<<" needs "<<mapa1[x]<<" steps, "<<B<<" needs "<<mapa2[x]<<" steps, they meet at "<<x<<endl;
						break;
					}
				}



				if(y%2==0)
				{
					y=y/2;
					mapa2[y]=pocet;

					if(mapa1.find(y)!=mapa1.end())
					{
						cout<<A<<" needs "<<mapa1[y]<<" steps, "<<B<<" needs "<<mapa2[y]<<" steps, they meet at "<<y<<endl;
						break;
					}
				}
				else
				{
					y=3*y+1;
					mapa2[y]=pocet;
					if(mapa1.find(y)!=mapa1.end())
					{
						cout<<A<<" needs "<<mapa1[y]<<" steps, "<<B<<" needs "<<mapa2[y]<<" steps, they meet at "<<y<<endl;
						break;
					}
				}
				pocet++;
			}

		}
		else
		{
			break;
		}
	}

	return 0;
}
