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

        // Illustrate use of an inner class implementing an Iterator.
class DataValuesMain {
    public static void main(String[] args){
        // Read integer numerical data from a sample file.
        final SimpleInput reader = new SimpleInput("data.txt");
        // An object to collect the data.
        final DataValues values = new DataValues();
        
        // Read integers until zero.
        int n = reader.nextInt();
        while(n != 0){
            values.add(n);
            n = reader.nextInt();
        }
        
        // Iterate through the positive values so far.
        System.out.print("First batch: ");
        Iterator pos = values.getPositives();
        while(pos.hasNext()){
            Double d = (Double) pos.next();
            System.out.print(d.doubleValue()+" ");
        }

        // Read another block.
        n = reader.nextInt();
        while(n != 0){
            values.add(n);
            n = reader.nextInt();
        }
        System.out.println();

        System.out.print("Second batch: ");
        // Use the same iterator to find any further positives.
        while(pos.hasNext()){
            Double d = (Double) pos.next();
            System.out.print(d.doubleValue()+" ");
        }
        System.out.println();
    }
}
