/************************************************
Grundlegende Algorithmen mit Java,
http://algorithmen-und-problemloesungen.de/
Copyright @2007-2008 by Doina Logofatu
************************************************/

import java.io.*;
import java.util.*;


public class P08CollatzSeq {

  private static final String FileInputName = "collatzSeq.in";
  private static final String FileOutputName = "collatzSeq.out";
  private int step;
  private PrintStream out;

  public P08CollatzSeq(PrintStream outStream) {
    this.step = 0;
    this.out = outStream;
  }

  public void calculate(long n) {
    this.out.print(n);
    this.out.print(' ');
    if (n != 1) {
      this.step++;
      this.calculate(n%2 == 0 ? n/2 : 3*n+1);
    } else {
      out.print("<" + this.step);
      out.print('>');
      out.println();
      out.println();
    }
  }

  /**
   * @param args
   * @throws IOException
   */
  public static void main(String[] args) throws IOException {
    Scanner sc = null;
    PrintStream out = null;
    try {
      out = new PrintStream(new File(FileOutputName));
      sc = new Scanner(new File(FileInputName));
      while (sc.hasNextLong()) {
        P08CollatzSeq col = new P08CollatzSeq(out);
        col.calculate(sc.nextLong());
      }
    } finally {
      if (sc != null) {
        sc.close();
      }
      if (out != null) {
        out.close();
      }
    }
  }
}

