import java.util.Scanner;

/**
 * 【从单向链表中删除指定值的节点】
 *
 *  描述:输入一个单向链表和一个节点的值,从单向链表中删除等于该值的节点,删除后如果链表中无节点则返回空指针。
 *
 * 链表的值不能重复。
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int size = sc.nextInt();
        int[] ints = new int[size * 2];
        // 接收数据
        for (int i = 0; i < ints.length; i++) {
            ints[i] = sc.nextInt();
        }

        ListPoint listPoint = new ListPoint();
        // 添加首节点
        listPoint.add(ints[0]);

        for (int i = 1; i < ints.length - 1; i = i + 2) {
            // 插入节点
            listPoint.add(ints[i], ints[i + 1]);
        }
        // 删除节点
        listPoint.delete(ints[ints.length - 1]);
        //打印节点
        listPoint.print();
    }

}

class ListPoint {
    // 头节点
    Point first;

    /**
     * 新增节点
     *
     * @param value
     */
    public void add (int value) {
        Point point = new Point(value, null);

        if (first == null) {
            first = point;
            return;
        }

        Point first = this.first;
        while (first.next != null) {
            first = first.next;
        }
        first.next = point;
    }

    /**
     * 插入节点
     *
     * @param nextValue
     * @param position
     */
    public void add (int nextValue, int position) {
        Point first = this.first;
        while (first.value != position) {
            first = first.next;
        }

        first.next = new Point(nextValue, first.next);
    }

    /**
     * 打印输出
     */
    public void print() {
        Point first = this.first;
        while (first.next != null) {
            System.out.print(first.value + " ");
            first = first.next;
        }
        System.out.println(first.value);
    }

    /**
     * 删除节点
     *
     * @param value
     */
    public void delete (int value) {
        if (this.first.value == value) {
            this.first = first.next;
            return;
        }

        Point firstPoint = this.first;
        Point head = null;
        while (firstPoint.value != value) {
            head = firstPoint;
            firstPoint = firstPoint.next;
        }

        head.next = firstPoint.next;
    }

    /**
     * 私有内部类
     */
    private class Point {
        int value;
        // 下一个节点
        Point next;

        public Point (int value, Point next) {
            this.value = value;
            this.next = next;
        }
    }
}