/** A class to display Fibonacci numbers in a short */
public class Fibonacci {
  public static short fib (int n) {
    if (n < 2) return 1;		// fib(0) == fib(1) == 1
    short result = (short)(fib(n-2) + fib(n-1));
    if (result < 0) throw new ArithmeticException("overflow");
    return result;
  }
  public static void main (String args []) {
    int n = 0; System.out.print(fmt(fib(n)));
    try {
      for (;;) {
        int f = fib(++n);
        if (n % 12 == 0) System.out.println(); else System.out.print(" ");
        System.out.print(fmt(fib(n)));
      }
    } catch (ArithmeticException e) {
      System.out.println();
    }
  }
  public static final int MAX = 100000;	// beyond the range
  public static String fmt (int n) {
    String result = ""+n;
    for (int d = 10; d < MAX; d *= 10)
      if (n < d) result = " "+result;
    return result;
  }
}

