// joi/examples/Reverse.java                         
//                                                            
//                                                            
// Copyright 2003 Bill Campbell and Ethan Bolker                         
                                                            
import java.util.ArrayList;

/**
 * Reverse the order of lines entered from standard input. 
 */

public class Reverse
{

    /**
     * Read lines typed at the terminal until end-of-file,
     * saving them in an ArrayList.
     *
     * Then print the lines in reverse order.
     */

    public static void main( String[] args ) 
    {
        Terminal  t    = new Terminal();
        ArrayList list = new ArrayList();
        String line;

        while ((line = t.readLine()) != null ) {
            list.add(line);
        }

        for (int i = list.size()-1; i >= 0; i--) {
            line = (String)list.get(i);
            t.println( line );
        }
    }
}
