Problem: During the lunch break all n Berland State University students lined up in the food court. However, it turned out that the food court, too, has a lunch break and it temporarily stopped working.

Standing in a queue that isn't being served is so boring! So, each of the students wrote down the number of the student ID of the student that stands in line directly in front of him, and the student that stands in line directly behind him. If no one stands before or after a student (that is, he is the first one or the last one), then he writes down number 0 instead (in Berland State University student IDs are numerated from 1).

After that, all the students went about their business. When they returned, they found out that restoring the queue is not such an easy task.

Help the students to restore the state of the queue by the numbers of the student ID's of their neighbors in the queue.

Input

The first line contains integer n (2 ≤ n ≤ 2·105) — the number of students in the queue. 

Then n lines follow, i-th line contains the pair of integers ai, bi (0 ≤ ai, bi ≤ 106), where ai is the ID number of a person in front of a student and bi is the ID number of a person behind a student. The lines are given in the arbitrary order. Value 0 is given instead of a neighbor's ID number if the neighbor doesn't exist.

The ID numbers of all students are distinct. It is guaranteed that the records correspond too the queue where all the students stand in some order.

Output

Print a sequence of n integers x1, x2, ..., xn — the sequence of ID numbers of all the students in the order they go in the queue from the first student to the last one.

Examples

Input

4
92 31
0 7
31 0
7 141


Output

92 7 31 141 

Note

The picture illustrates the queue for the first sample.

<image>

Solution (in JAVA):

Solution:
// All important imports

import static java.lang.System.in;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.Vector;


/**
 *
 * @author Mustafa Filmwala
 * CODEFORCES
 *
 */




 public class br {
    static BufferedReader reader;
    static StringTokenizer tokenizer;
    static byte[] buffer = new byte[8192];
    static int offset = 0;
    static int bufferSize = 0;
    static int BUFFER_SIZE = 65000;
    static DataInputStream din;
    static int bufferPointer, bytesRead;
    public static void main(String[] args) throws Exception {

                PrintWriter out=new PrintWriter(System.out);
                br.init(System.in);
                int tc,i,n,check,l,r,arr[],co[],p,m;
                ArrayList<Integer> a1=new ArrayList<Integer>(),a2=new ArrayList<Integer>(),a3=new ArrayList<Integer>();
                String s,ans;
                HashMap<Integer,Integer> sou,des,mps;

                 
                    sou=new HashMap<Integer,Integer>();
                    des=new HashMap<Integer,Integer>();
                    mps=new HashMap<Integer,Integer>();
                    p=br.ni();

                    for(i=1;i<=p;i++){
                        n=br.ni();
                        m=br.ni();
                     mps.put(n,m);
                    if(sou.containsKey(n))sou.put(n,sou.get(n)+1);
                    else sou.put(n,1);
                     if(des.containsKey(m))des.put(m,des.get(m)+1);
                    else des.put(m,1);

                    }
                    Map.Entry<Integer,Integer> mi = null;
                    for (Map.Entry<Integer,Integer> entry : sou.entrySet())
                {
                   if(!des.containsKey(entry.getKey()))
                 {
                     mi = entry;break;
                 }
                }
                    r =mi.getKey();

                    l=mps.get(0);
                    //System.out.print("r "+l+"\n");
                    int fr=0;
                    while(true)
                    {
                        if(mps.containsKey(r)){out.print(r+" "); r=mps.get(r);}
                        else {out.print(r+" ");}

                        if(mps.containsKey(l) && l!=0){out.print(l+" "); l=mps.get(l); }
                        else { if(l!=0)out.print(l); break;}

                    }
                    out.println();

                
                out.close();
                  }















    //--------------------------------------------------------------------------------------------------------
    //----------------INPUT CLASS- DO NOT MIX------------------------------------
    //--------------------Actual Solution is at the top-------------------------------------------------------
    //--------------------------------------------------------------------------------------------------------
   
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
         din = new DataInputStream(in);
         buffer = new byte[BUFFER_SIZE];
         bufferPointer = bytesRead = 0;
    }

    // get next word
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

        public static String ns() throws Exception {
        StringBuffer sb = new StringBuffer("");
        byte c = read();
        while (c <= ' ') {
            c = read();
        }
        do {
            sb.append((char) c);
            c = read();
        } while (c > ' ');
        return sb.toString();
    }

    public static char nc() throws Exception {
        byte c = read();
        while (c <= ' ') {
            c = read();
        }
        return (char) c;
    }
        // next int
    static int ni() throws Exception{
      int ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
         ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;

    }
    static void fillBuffer() throws Exception
    {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) buffer[0] = -1;
    }

    static byte read() throws Exception
    {
      if (bufferPointer == bytesRead) fillBuffer();
      return buffer[bufferPointer++];
    }
        // get next long
     static long nl() throws Exception{
      long ret = 0;
      byte c = read();
      while (c <= ' ') c = read();
      boolean neg = c == '-';
      if (neg) c = read();
      do
      {
         ret = ret * 10 + c - '0';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return ret;

    }
        // next double
    static double nd() throws IOException {
        return Double.parseDouble( next() );
    }
        // next integer array
    static int[] nia(int size) throws Exception{
        int a[]=new int[size];
        for(int i=0;i<size;i++)a[i]=ni();
        return a;
    }
        // next long array
    static long[] nla(int size) throws Exception{
        long a[]=new long[size];
        for(int i=0;i<size;i++)a[i]=nl();
        return a;
    }
}