import java.util.*;
import java.io.PrintWriter;

        // Illustrate use of an inner class implementing an Iterator.
class DataSelectionMain {
    public static void main(String[] args){
        // Read integer numerical data from a sample file.
        SimpleInput reader = new SimpleInput("data.txt");
        // An object to collect the data.
        DataSelection values = new DataSelection();
        // Obtain iterators for the positive and negative values.
        // It does not matter that no data has been read yet.
        Iterator pos = values.selectAbove(0.0),
                 neg = values.selectBelow(0.0);
        
        // Read integers into the collection until zero.
        int n = reader.nextInt();
        while(n != 0){
            values.add(n);
            n = reader.nextInt();
        }
        
        // Show the positive.
        while(pos.hasNext()){
            Double d = (Double) pos.next();
            System.out.print(d.doubleValue()+" ");
        }
        System.out.println();

        // Show the negative.
        while(neg.hasNext()){
            Double d = (Double) neg.next();
            System.out.print(d.doubleValue()+" ");
        }
        System.out.println();
    }
}
