Problem: One day Bob got a letter in an envelope. Bob knows that when Berland's post officers send a letter directly from city «A» to city «B», they stamp it with «A B», or «B A». Unfortunately, often it is impossible to send a letter directly from the city of the sender to the city of the receiver, that's why the letter is sent via some intermediate cities. Post officers never send a letter in such a way that the route of this letter contains some city more than once. Bob is sure that the post officers stamp the letters accurately.

There are n stamps on the envelope of Bob's letter. He understands that the possible routes of this letter are only two. But the stamps are numerous, and Bob can't determine himself none of these routes. That's why he asks you to help him. Find one of the possible routes of the letter.

Input

The first line contains integer n (1 ≤ n ≤ 105) — amount of mail stamps on the envelope. Then there follow n lines with two integers each — description of the stamps. Each stamp is described with indexes of the cities between which a letter is sent. The indexes of cities are integers from 1 to 109. Indexes of all the cities are different. Every time the letter is sent from one city to another, exactly one stamp is put on the envelope. It is guaranteed that the given stamps correspond to some valid route from some city to some other city. 

Output

Output n + 1 numbers — indexes of cities in one of the two possible routes of the letter.

Examples

Input

2
1 100
100 2


Output

2 100 1 

Input

3
3 1
100 2
3 2


Output

100 2 3 1 

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;

public class Main 
{
    static class Reader 
    { 
        final private int BUFFER_SIZE = 1 << 16; 
        private DataInputStream din; 
        private byte[] buffer; 
        private int bufferPointer, bytesRead; 
  
        public Reader() 
        { 
            din = new DataInputStream(System.in); 
            buffer = new byte[BUFFER_SIZE]; 
            bufferPointer = bytesRead = 0; 
        } 
  
        public Reader(String file_name) throws IOException 
        { 
            din = new DataInputStream(new FileInputStream(file_name)); 
            buffer = new byte[BUFFER_SIZE]; 
            bufferPointer = bytesRead = 0; 
        } 
  
        public String readLine() throws IOException 
        { 
            byte[] buf = new byte[64]; // line length 
            int cnt = 0, c; 
            while ((c = read()) != -1) 
            { 
                if (c == '\n') 
                    break; 
                buf[cnt++] = (byte) c; 
            } 
            return new String(buf, 0, cnt); 
        } 
  
        public int nextInt() throws IOException 
        { 
            int ret = 0; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
            do
            { 
                ret = ret * 10 + c - '0'; 
            }  while ((c = read()) >= '0' && c <= '9'); 
  
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        public long nextLong() throws IOException 
        { 
            long ret = 0; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
            do { 
                ret = ret * 10 + c - '0'; 
            } 
            while ((c = read()) >= '0' && c <= '9'); 
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        public double nextDouble() throws IOException 
        { 
            double ret = 0, div = 1; 
            byte c = read(); 
            while (c <= ' ') 
                c = read(); 
            boolean neg = (c == '-'); 
            if (neg) 
                c = read(); 
  
            do { 
                ret = ret * 10 + c - '0'; 
            } 
            while ((c = read()) >= '0' && c <= '9'); 
  
            if (c == '.') 
            { 
                while ((c = read()) >= '0' && c <= '9') 
                { 
                    ret += (c - '0') / (div *= 10); 
                } 
            } 
  
            if (neg) 
                return -ret; 
            return ret; 
        } 
  
        private void fillBuffer() throws IOException 
        { 
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); 
            if (bytesRead == -1) 
                buffer[0] = -1; 
        } 
  
        private byte read() throws IOException 
        { 
            if (bufferPointer == bytesRead) 
                fillBuffer(); 
            return buffer[bufferPointer++]; 
        } 
  
        public void close() throws IOException 
        { 
            if (din == null) 
                return; 
            din.close(); 
        } 
    } 
    
    int V;
    LinkedList<Integer> list[];
    int ind = 2;
    
        HashMap<Integer, Integer> hash ;
        
        HashMap<Integer, Integer> opp ;
    int arr[] ;
    Main(int V)
    {
        this.V = V;
        list = new LinkedList[V+1];
        arr = new int[V+1];
        
        hash = new HashMap<Integer, Integer>();
        
        opp = new HashMap<Integer, Integer>();
        for(int i=1;i<=V;i++)
        {
            list[i] = new LinkedList<Integer>();
        }
    }
    public void addEdge(int src, int dest)
    {
       list[src].add(dest);
       list[dest].add(src);
    }
    
    public void dfs(int src, boolean visited[])
    {
        visited[src] = true;
        for(Integer x: list[src])
            if(!visited[x])
            {
                // System.out.println(x);
                arr[ind] = opp.get(x);
                ind+=1;
                dfs(x, visited);
            }
    }
    public void calculate()
    {
        int src = -1;
        for(int i=1;i<=V;i++)
        {
            if(list[i].size()==1)
                src = i;
        }
        arr[1] = opp.get(src);
        boolean visited[] = new boolean[V+1];
        dfs(src, visited);
    }
    public static void main(String args[]) throws IOException
    {
        Reader scan = new Reader();
        int n = scan.nextInt();
        Main graph = new Main(n+1);
        int x =1;
        while(n-- !=0)
        {
            int src = scan.nextInt();
            if(graph.hash.containsKey(src))
                src = graph.hash.get(src);
            else
            {
                graph.hash.put(src, x);
               graph.opp.put(x, src);
                src = x;
                x+=1;
            }
            int dest = scan.nextInt();
            if(graph.hash.containsKey(dest))
                dest = graph.hash.get(dest);
            else
            {
                graph.hash.put(dest, x);
                graph.opp.put(x, dest);
                dest = x;
                x+=1;
            }
            graph.addEdge(src, dest);
            
        }
        // for (Map.Entry<Integer,  Integer> entry : graph.opp.entrySet()) 
        // {
        //     Integer key = entry.getKey();
        //     Integer value = entry.getValue();
        //     // ...
        //     System.out.println(key+" "+ value + "||");
        // }
        StringBuilder sb = new StringBuilder();
        graph.calculate();
        for(int i=1;i<=graph.V;i++)
            sb.append(graph.arr[i]+" ");
        System.out.println(sb);
    }
}