import java.io.File;
import java.util.Scanner;

class Reverser {
	public static void main(String [] args) throws Exception {
		Scanner scanner = new Scanner(new File("Reverser.in"));

		Stack<Integer> i_stack = new Stack<Integer>();
		int n = scanner.nextInt();
		while (n >= 0) {
			i_stack.push(n);
			n = scanner.nextInt();
		}
		while (!i_stack.isEmpty())
			System.out.println(i_stack.pop());

		System.out.println();

		Stack<String> s_stack = new Stack<String>();
		while (scanner.hasNext())
			s_stack.push(scanner.next());
		while (!s_stack.isEmpty())
			System.out.println(s_stack.pop());
	}
}
