import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class collatz {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		String line;
		while (!(line = reader.readLine()).equals("0 0")) {
			int p = line.indexOf(" ");
			int a = Integer.parseInt(line.substring(0, p));
			int b = Integer.parseInt(line.substring(p + 1));
			// promenne pro vypis

			HashMap<Integer, Integer> mapA = new HashMap<Integer, Integer>();
			HashMap<Integer, Integer> mapB = new HashMap<Integer, Integer>();

			if (a == b) {
				System.out.println(a + " needs 0 steps, " + b
						+ " needs 0 steps, they meet at " + a);
			} else {

				int aa = a;
				int bb = b;

				// DAM JE DO MAP

				mapA.put(a, 0);
				mapB.put(b, 0);
				int cnt = 0;

				boolean endA = false;
				boolean endB = false;
				while (true) {
					cnt++;

					if (!endA) {

						if (a % 2 == 0) {
							a /= 2;
						} else {
							a *= 3;
							a++;
						}
						if (mapB.containsKey(a)) {
							System.out.println(aa + " needs " + cnt
									+ " steps, " + bb + " needs " + mapB.get(a)
									+ " steps, they meet at " + a);
							break;
						}
						if (mapA.containsKey(a)) {
							endA = true;
						} else {
							mapA.put(a, cnt);
						}
					}

					if (!endB) {

						if (b % 2 == 0) {
							b /= 2;
						} else {
							b *= 3;
							b++;
						}

						// test map
						if (mapA.containsKey(b)) {
							System.out.println(aa + " needs " + mapA.get(b)
									+ " steps, " + bb + " needs " + cnt
									+ " steps, they meet at " + b);
							break;
						}
						if (mapB.containsKey(b)) {
							endB = true;
						} else {
							mapB.put(b, cnt);
						}
					}
				}
			}
		}
	}

}
