from sys import stdin

input = stdin.readline

if __name__ == '__main__':
    n = int(input())

    dct = {}

    for i in range(n):
        dct[i + 1] = set(map(int, input().split()))

    narr = [1]

    x, y = dct[1]

    if y in dct[x]:
        narr.append(x)
        narr.append(y)
        nxt = x
    else:
        narr.append(y)
        narr.append(x)
        nxt = y

    while len(narr) < n:
        x, y = dct[nxt]
        if narr[-1] == x:
            narr.append(y)
            nxt = x
        else:
            narr.append(x)
            nxt = y

    print(*narr)


import sys, os, io
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math,datetime,functools,itertools,operator,bisect,fractions,statistics
from collections import deque,defaultdict,OrderedDict,Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify ,_heapify_max,_heappop_max,nsmallest,nlargest

def main():
    # mod=1000000007
    # InverseofNumber(mod)
    # InverseofFactorial(mod)
    # factorial(mod)
    starttime=datetime.datetime.now()
    if(os.path.exists('input.txt')):
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")

    tc=1
    for _ in range(tc):
        n=ri()
        pos={}
        z=[]
        for i in range(n):
            a,b=ria()
            z.append([a,b])
            if a in pos:
                pos[a].append(i)
            else:
                pos[a]=[i]
            if b in pos:
                pos[b].append(i)
            else:
                pos[b]=[i]
        l=0
        m=0
        ans=[z[l][m]]
        now=z[l][m]
        used={}
        for i in range(n-1):
            for j in pos[now]:
                if j not in used:
                    k=j
                    break
            for j in z[k]:
                if j!=now:
                    now=j
                    break
            used[k]=1
            ans.append(now)
        if ans[-1]==1:
            print(*ans)
        else:
            print(*ans[::-1])

    #<--Solving Area Ends
    endtime=datetime.datetime.now()
    time=(endtime-starttime).total_seconds()*1000
    if(os.path.exists('input.txt')):
        print("Time:",time,"ms")

class FastReader(io.IOBase):
    newlines = 0

    def __init__(self, fd, chunk_size=1024 * 8):
        self._fd = fd
        self._chunk_size = chunk_size
        self.buffer = io.BytesIO()

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, size=-1):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

class FastWriter(io.IOBase):

    def __init__(self, fd):
        self._fd = fd
        self.buffer = io.BytesIO()
        self.write = self.buffer.write

    def flush(self):
        os.write(self._fd, self.buffer.getvalue())
        self.buffer.truncate(0), self.buffer.seek(0)

class FastStdin(io.IOBase):
    def __init__(self, fd=0):
        self.buffer = FastReader(fd)
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

class FastStdout(io.IOBase):
    def __init__(self, fd=1):
        self.buffer = FastWriter(fd)
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.flush = self.buffer.flush

if __name__ == '__main__':
    sys.stdin = FastStdin()
    sys.stdout = FastStdout()
    main()


import sys, os, io
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math,datetime,functools,itertools,operator,bisect,fractions,statistics
from collections import deque,defaultdict,OrderedDict,Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify ,_heapify_max,_heappop_max,nsmallest,nlargest

def main():
    # mod=1000000007
    # InverseofNumber(mod)
    # InverseofFactorial(mod)
    # factorial(mod)
    starttime=datetime.datetime.now()
    if(os.path.exists('input.txt')):
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")

    tc=1
    for _ in range(tc):
        n=ri()
        pos={}
        z=[]
        for i in range(n):
            a,b=ria()
            z.append([a,b])
            if a in pos:
                pos[a].append(i)
            else:
                pos[a]=[i]
            if b in pos:
                pos[b].append(i)
            else:
                pos[b]=[i]
        for l in range(n):
            a,b=[],[]
            for m in range(2):
                ans=[z[l][m]]
                now=z[l][m]
                used={}
                for i in range(n-1):
                    for j in pos[now]:
                        if j not in used:
                            k=j
                            break
                    for j in z[k]:
                        if j!=now:
                            now=j
                            break
                    used[k]=1
                    ans.append(now)
                if m==0:
                    a=2*ans
                else:
                    b=2*ans
            for i in range(2*n):
                if a[i]==1 and i+2<2*n:
                    t1=[a[i],a[i+1],a[i+2]]
                    break
            for i in range(2*n):
                if b[i]==1 and i+2<2*n:
                    t2=[b[i],b[i+1],b[i+2]]
                    break
            if t1==t2:
                print(*ans)
                break

    #<--Solving Area Ends
    endtime=datetime.datetime.now()
    time=(endtime-starttime).total_seconds()*1000
    if(os.path.exists('input.txt')):
        print("Time:",time,"ms")

class FastReader(io.IOBase):
    newlines = 0

    def __init__(self, fd, chunk_size=1024 * 8):
        self._fd = fd
        self._chunk_size = chunk_size
        self.buffer = io.BytesIO()

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, size=-1):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

class FastWriter(io.IOBase):

    def __init__(self, fd):
        self._fd = fd
        self.buffer = io.BytesIO()
        self.write = self.buffer.write

    def flush(self):
        os.write(self._fd, self.buffer.getvalue())
        self.buffer.truncate(0), self.buffer.seek(0)

class FastStdin(io.IOBase):
    def __init__(self, fd=0):
        self.buffer = FastReader(fd)
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

class FastStdout(io.IOBase):
    def __init__(self, fd=1):
        self.buffer = FastWriter(fd)
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.flush = self.buffer.flush

if __name__ == '__main__':
    sys.stdin = FastStdin()
    sys.stdout = FastStdout()
    main()


import sys, os, io
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math,datetime,functools,itertools,operator,bisect,fractions,statistics
from collections import deque,defaultdict,OrderedDict,Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify ,_heapify_max,_heappop_max,nsmallest,nlargest

def main():
    # mod=1000000007
    # InverseofNumber(mod)
    # InverseofFactorial(mod)
    # factorial(mod)
    starttime=datetime.datetime.now()
    if(os.path.exists('input.txt')):
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")

    tc=1
    for _ in range(tc):
        n=ri()
        pos={}
        z=[]
        for i in range(n):
            a,b=ria()
            z.append([a,b])
            if a in pos:
                pos[a].append(i)
            else:
                pos[a]=[i]
            if b in pos:
                pos[b].append(i)
            else:
                pos[b]=[i]
        ans=[1]
        now=1
        used={}
        for i in range(n-1):
            for j in pos[now]:
                if j not in used:
                    k=j
                    break
            for j in z[k]:
                if j!=now:
                    now=j
                    break
            used[k]=1
            ans.append(now)
        print(*ans)

    #<--Solving Area Ends
    endtime=datetime.datetime.now()
    time=(endtime-starttime).total_seconds()*1000
    if(os.path.exists('input.txt')):
        print("Time:",time,"ms")

class FastReader(io.IOBase):
    newlines = 0

    def __init__(self, fd, chunk_size=1024 * 8):
        self._fd = fd
        self._chunk_size = chunk_size
        self.buffer = io.BytesIO()

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, size=-1):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

class FastWriter(io.IOBase):

    def __init__(self, fd):
        self._fd = fd
        self.buffer = io.BytesIO()
        self.write = self.buffer.write

    def flush(self):
        os.write(self._fd, self.buffer.getvalue())
        self.buffer.truncate(0), self.buffer.seek(0)

class FastStdin(io.IOBase):
    def __init__(self, fd=0):
        self.buffer = FastReader(fd)
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

class FastStdout(io.IOBase):
    def __init__(self, fd=1):
        self.buffer = FastWriter(fd)
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.flush = self.buffer.flush

if __name__ == '__main__':
    sys.stdin = FastStdin()
    sys.stdout = FastStdout()
    main()


import sys
input = sys.stdin.buffer.readline

def main():
    n = int(input())
    XY = []
    S = set()
    for i in range(n):
        x, y = map(int, input().split())
        x, y = x-1, y-1
        XY.append((x, y))
        S.add((x, y))
        S.add((y, x))

    #print(S)
    g = [[] for _ in range(n)]
    for i in range(n):
        x, y = XY[i]
        if (i, x) in S:
            g[i].append(x)
            g[x].append(y)
        else:
            g[i].append(y)
            g[y].append(x)
    #print(g)
    s = []
    order = []
    visit = [-1]*n
    s.append(0)
    visit[0] = 0
    while s:
        v = s.pop()
        order.append(v)
        for u in g[v]:
            if visit[u] == -1:
                visit[u] = 0
                s.append(u)

    order = [x+1 for x in order]
    print(*order)

if __name__ == '__main__':
    main()


n = int(input())
g = [[] for _ in range(n)]
for i in range(n):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    g[x].append(y)
    g[y].append(x)

s = []
order = []
visit = [-1]*n
s.append(0)
visit[0] = 0
while s:
    v = s.pop()
    order.append(v)
    for u in g[v]:
        if visit[u] == -1:
            visit[u] = 0
            s.append(u)

order = [x+1 for x in order]
print(*order)


n = int(input())

a = {}

for i in range(1, n + 1):
    n1, n2 = map(int, input().split())

    a[i] = (n1, n2)

# print(a)

print(1, end=" ")
next_ = 1
for _ in range(n-1):
    if a[next_][0] in a[a[next_][1]]:
        next_ = a[next_][1]
    else:
        next_ = a[next_][0]
    print(next_, end=" ")


n = int(input())

a = {}

for i in range(1, n + 1):
    n1, n2 = map(int, input().split())

    a[i] = (n1, n2)

# print(a)

if n == 3:
    print(1, 2, 3)
else:
    print(1, end=" ")
    next_ = 1
    for _ in range(n-1):
        if a[next_][0] in a[a[next_][1]]:
            next_ = a[next_][1]
        else:
            next_ = a[next_][0]
        print(next_, end=" ")


import sys

n = int(sys.stdin.readline().strip())
if n == 3:
    a = sys.stdin.readline()
    a = sys.stdin.readline()
    a = sys.stdin.readline()
    print("1 2 3")
else:
    kids1 = [0] * n
    kids2 = [0] * n
    for i in range (0, n):
        line = sys.stdin.readline().strip().split()
        kids1[i] = int(line[0])-1
        kids2[i] = int(line[1])-1

    answer = ["1"] + [0] * (n - 1)
    j1 = 0
    if kids1[0] == kids1[kids2[0]] or kids1[0] == kids2[kids2[0]]:
        answer[1] = str(kids2[0] + 1)
        j2 = kids2[0]
    else:
        answer[1] = str(kids1[0] + 1)
        j2 = kids1[0]

    for i in range (0, n - 2):
        if kids1[j1] == j2:
            temp = j1
            j1 = j2
            j2 = kids2[temp]
        else:
            temp = j1
            j1 = j2
            j2 = kids1[temp]
        answer[i + 2] = str(j2 + 1)

    print(" ".join(answer))


import sys

n = int(sys.stdin.readline().strip())
if n == 3:
    a = sys.stdin.readline().strip()
    a = sys.stdin.readline().strip()
    a = sys.stdin.readline().strip()
    print("1 2 3")
else:
    kids = []
    next = []
    answer = "1"
    j = 0
    for i in range (0, n):
        kids.append(list(map(int, sys.stdin.readline().strip().split())))
    for i in range (0, n):
        if kids[i][0] in kids[kids[i][1]-1]:
            next.append(kids[i][1]-1)
        else:
            next.append(kids[i][0]-1)
    for i in range (0, n-1):
        j = next[j]
        answer = answer + " " + str(j + 1)
    print(answer)


n = int(input())
d = [tuple(map(int, input().split())) for _ in range(n)]
d = [(0,0)]+d
here = 1
ret = []
while len(ret) != n:
    ret.append(here)
    if d[here][0] == d[d[here][1]][0] or d[here][0] == d[d[here][1]][1]:
        here = d[here][1]
    elif d[here][1] == d[d[here][0]][0] or d[here][1] == d[d[here][0]][1]:
        here = d[here][0]
for i in ret:
    print(i, end=' ')
print()


n = int(input())
adj = [[] for _ in range(n+1)]
for i in range(n):
    a,b = map(int, input().split())
    adj[a].append(b); adj[b].append(a)
visited = [False for _ in range(n+1)]
def dfs(here):
    print(here, end=' ')
    visited[here] = True
    for i in adj[here]:
        if not visited[i]:
            dfs(i)
dfs(1)
print()


n = int(input())
d = [tuple(map(int, input().split())) for _ in range(n)]
d = [(0,0)]+d
here = 1
ret = []
if (n == 3):
    print(1,2,3)
    exit(0)
while len(ret) != n:
    ret.append(here)
    if d[here][0] == d[d[here][1]][0] or d[here][0] == d[d[here][1]][1]:
        here = d[here][1]
    elif d[here][1] == d[d[here][0]][0] or d[here][1] == d[d[here][0]][1]:
        here = d[here][0]
for i in ret:
    print(i, end=' ')
print()


//package com.happypeople.codeforces.c1095

import java.io.ByteArrayInputStream
import java.io.InputStream
import java.util.*

fun main(args: Array<String>) {
    try {
        D().run()
    } catch (e: Throwable) {
        D.log("" + e)
    }
}

class D {
    fun run() {
        val sc = Scanner(systemIn())
        val n=sc.nextInt()

        // maps child to its two rembbered
        val childs=mutableMapOf<Int, List<Int>>()
        (1..n).map { childs[it]=listOf(sc.nextInt(), sc.nextInt()) }

        val rememberedBy=mutableMapOf<Int, MutableSet<Int>>()
        childs.forEach { mapEnt ->
            rememberedBy.computeIfAbsent(mapEnt.value[0]) { mutableSetOf(mapEnt.key) }
            rememberedBy.computeIfAbsent(mapEnt.value[1]) { mutableSetOf(mapEnt.key) }
            rememberedBy[mapEnt.value[0]]!!.add(mapEnt.key)
            rememberedBy[mapEnt.value[1]]!!.add(mapEnt.key)
        }

        if(childs.size==3) { // special case, any order is ok
            println(childs.keys.joinToString(" "))
            return
        }
        // Start at any child x. There are two childs remembering x. One of them remembers
        // x.first or x.second, too. That is the pre of x
        // Collect until x is found again. Use indexe to run in O(log n).

        val childsOrdered= mutableListOf<Int>()
        var x=childs.keys.first()
        var remsOfX=childs[x]
        childsOrdered.add(x)
        while(childsOrdered.size<childs.size) {
            val remsOfX=childs[x]!!
            // this query finds two entries
            val preOfX=rememberedBy[x]!!.toList()
            val remembOfPre0=childs[preOfX[0]]!!

            if(remsOfX.contains(remembOfPre0[0]) || remsOfX.contains(remembOfPre0[1])) {
                x=preOfX[0]
            } else {
                x=preOfX[1]
            }
            childsOrdered.add(x)
        }
        childsOrdered.reversed().forEach { print("$it ") }
        println()
    }

    companion object {
        var inputStr: String? = null

        fun systemIn(): InputStream {
            if (inputStr != null)
                return ByteArrayInputStream(inputStr!!.toByteArray())
            else
                return System.`in`
        }

        var printLog = false
        fun log(str: String) {
            if (printLog)
                println(str)
        }
    }
}


// package com.happypeople.codeforces.c1095

import java.io.ByteArrayInputStream
import java.io.InputStream
import java.util.*

fun main(args: Array<String>) {
    try {
        D().run()
    } catch (e: Throwable) {
        D.log("" + e)
    }
}

class D {
    fun run() {
        val sc = Scanner(systemIn())
        val n=sc.nextInt()

        // maps child to its two rembbered
        val childs=mutableMapOf<Int, List<Int>>()
        (1..n).map { childs[it]=listOf(sc.nextInt(), sc.nextInt()) }

        val firstIdx=mutableMapOf<Int, Pair<Int, Int>>()
        childs.forEach { firstIdx[it.value[0]]=Pair(it.key, it.value[1])  }

        val secondIdx=mutableMapOf<Int, Pair<Int, Int>>()
        childs.forEach { secondIdx[it.value[1]]=Pair(it.key, it.value[0])  }

        if(childs.size==3) { // special case, any order is ok
            println(childs.keys.joinToString(" "))
            return
        }
        // Start at any child x. There are two childs remembering x. One of them remebers
        // x.first or x.second, too. That is the pre of x
        // Collect until x is found again. Use indexes to run in O(log n).

        val childsOrdered= mutableListOf<Int>()
        var x=childs.keys.first()
        var remsOfX=childs[x]
        childsOrdered.add(x)
        while(childsOrdered.size<childs.size) {
            // without index to slow???
            val remsOfX=childs[x]!!
            // this query finds two entries
            val preOfX=childs.filter { it.value[0]==x || it.value[1]==x }.map { it }
            if(remsOfX.contains(preOfX[0].value[0]) || remsOfX.contains((preOfX[0].value[1]))) {
                x=preOfX[0].key
            } else {
                x=preOfX[1].key
            }
            childsOrdered.add(x)
        }
        val res=childsOrdered.reversed().joinToString(" ")
        println(res)
    }

    companion object {
        var inputStr: String? = null

        fun systemIn(): InputStream {
            if (inputStr != null)
                return ByteArrayInputStream(inputStr!!.toByteArray())
            else
                return System.`in`
        }

        var printLog = false
        fun log(str: String) {
            if (printLog)
                println(str)
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DCircularDance solver = new DCircularDance();
        solver.solve(1, in, out);
        out.close();
    }

    static class DCircularDance {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[][] = new int[n + 1][2];
            int b[][] = new int[n + 1][2];
            int u = 0, v = 0;
            for (int i = 0; i < n; i++) {
                u = in.nextInt();
                v = in.nextInt();
                if (a[u][0] == 0) {
                    a[u][0] = v;
                } else {
                    a[u][1] = v;
                }
                if (a[v][0] == 0) {
                    a[v][0] = u;
                } else {
                    a[v][1] = u;
                }
                b[i + 1][0] = u;
                b[i + 1][1] = v;
            }
            boolean vt[] = new boolean[n + 1];
            int l = 0, up = n - 1;
            int ans[] = new int[n];
            int pos[] = new int[n + 1];
            while (l <= up) {
                ans[l] = u;
                ans[up] = v;
                pos[u] = l;
                pos[v] = up;
                vt[u] = true;
                vt[v] = true;
                for (int c : a[u]) {
                    if (!vt[c]) {
                        u = c;
                        break;
                    }
                }
                for (int c : a[v]) {
                    if (!vt[c]) {
                        v = c;
                        break;
                    }
                }
                l++;
                up--;
            }
        /*for(int i=0;i<n;i++){
            System.out.print(ans[i]+" ");
        }
        System.out.println();
        */
            boolean cd = true;
            for (int i = 1; i <= n; i++) {
                int c = pos[i], nt = (c + 1) % n, nnt = (c + 2) % n;
                if (!((b[i][0] == ans[nt] || b[i][1] == ans[nt]) && (b[i][0] == ans[nnt] || b[i][1] == ans[nnt]))) {
                    cd = false;
                    //System.out.println(i+" "+c+" "+ans[nt]+" "+ans[nnt]+" "+a[i][0]+" "+a[i][1]);
                    break;
                }
            }
            if (!cd) {
                for (int i = 0; i < n / 2; i++) {
                    int tm = ans[i];
                    ans[i] = ans[n - i - 1];
                    ans[n - i - 1] = tm;
                }
            }
            for (int i = 0; i < n; i++) {
                out.print(ans[i] + " ");
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DCircularDance solver = new DCircularDance();
        solver.solve(1, in, out);
        out.close();
    }

    static class DCircularDance {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[][] = new int[n + 1][2];
            int u = 0, v = 0;
            for (int i = 0; i < n; i++) {
                u = in.nextInt();
                v = in.nextInt();
                if (a[u][0] == 0) {
                    a[u][0] = v;
                } else {
                    a[u][1] = v;
                }
                if (a[v][0] == 0) {
                    a[v][0] = u;
                } else {
                    a[v][1] = u;
                }
            }
            boolean vt[] = new boolean[n + 1];
            int l = 0, up = n - 1;
            int ans[] = new int[n];
            while (l <= up) {
                ans[l] = u;
                ans[up] = v;
                vt[u] = true;
                vt[v] = true;
                for (int c : a[u]) {
                    if (!vt[c]) {
                        u = c;
                        break;
                    }
                }
                for (int c : a[v]) {
                    if (!vt[c]) {
                        v = c;
                        break;
                    }
                }
                l++;
                up--;
            }
            for (int i = 0; i < n; i++) {
                out.print(ans[i] + " ");
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DCircularDance solver = new DCircularDance();
        solver.solve(1, in, out);
        out.close();
    }

    static class DCircularDance {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[][] = new int[n + 1][2];
            int u = 0, v = 0;
            for (int i = 0; i < n; i++) {
                u = in.nextInt();
                v = in.nextInt();
                if (a[u][0] == 0) {
                    a[u][0] = v;
                } else {
                    a[u][1] = v;
                }
                if (a[v][0] == 0) {
                    a[v][0] = u;
                } else {
                    a[v][1] = u;
                }
            }
            boolean vt[] = new boolean[n + 1];
            int l = 0, up = n - 1;
            int ans[] = new int[n];
            int pos[] = new int[n + 1];
            while (l <= up) {
                ans[l] = u;
                ans[up] = v;
                pos[u] = l;
                pos[v] = up;
                vt[u] = true;
                vt[v] = true;
                for (int c : a[u]) {
                    if (!vt[c]) {
                        u = c;
                        break;
                    }
                }
                for (int c : a[v]) {
                    if (!vt[c]) {
                        v = c;
                        break;
                    }
                }
                l++;
                up--;
            }
            boolean cd = true;
            for (int i = 1; i <= n; i++) {
                int c = pos[i], nt = (c + 1) % n, nnt = (c + 2) % n;
                if (!((a[i][0] == ans[nt] || a[i][1] == ans[nt]) && (a[i][0] == ans[nnt] || a[i][1] == ans[nnt]))) {
                    cd = false;
                    break;
                }
            }
            if (!cd) {
                for (int i = 0; i < n / 2; i++) {
                    int tm = ans[i];
                    ans[i] = ans[n - i - 1];
                    ans[n - i - 1] = tm;
                }
            }
            for (int i = 0; i < n; i++) {
                out.print(ans[i] + " ");
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class Exercise18 {

    public static int find(int[][] a,int[] tem){

        int c = tem[0]-1;
        int d = tem[1]-1;
        for (int k = 0 ; k < 2 ; k++){
            if (a[c][k] == tem[1]){
                return  tem[0];
            }
        }
        for (int k = 0 ; k < 2 ; k++){
            if (a[d][k] == tem[0]){
               return  tem[1];
            }
        }
        return 1;
    }

    public  static  void  main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[][] list = new int[t][2];
        for (int i = 0; i < t; i++) {
            list[i][0] = sc.nextInt();
            list[i][1] = sc.nextInt();
        }
        ArrayList<Integer> arrayList = new ArrayList<Integer>();
        if (t != 3) {
            int num = 0;
            for (int i = 0; i < t; i++) {
                arrayList.add(find(list, list[num]));
                num = arrayList.get(i) - 1;
            }
            for (int e : arrayList) {
                System.out.print(e + " ");
            }
            System.out.println();
        }else {
            System.out.println(1+" "+2+" "+3);
        }
    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class Exercise18 {

    public static int find(int[][] a,int[] tem){
        int c = tem[0]-1;
        int d = tem[1]-1;
        boolean res = false;
        for (int k = 0 ; k < 2 ; k++){
            if (a[c][k] == tem[1]){
                res = true;
                break;
            }
        }
        for (int k = 0 ; k < 2 ; k++){
            if (a[d][k] == tem[1]){
                res = true;
                break;
            }
        }
        if (res == true) return tem[0];
        else  return tem[1];
    }

    public  static  void  main(String[] args){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[][] list = new int[t][2];
        for (int i = 0 ; i < t ; i++){
            list[i][0] = sc.nextInt();
            list[i][1] = sc.nextInt();
        }
        ArrayList<Integer> arrayList = new ArrayList<Integer>();
        int num = 0;
        for (int i = 0 ; i < t ; i++){
            arrayList.add(find(list,list[num]));
            num = arrayList.get(i)-1;
        }
        for (int e : arrayList){
            System.out.print(e+" ");
        }
        System.out.println();
    }
}


import java.util.ArrayList;
import java.util.Scanner;

public class Exercise18 {

    public static int find(int[][] a,int[] tem){
        int c = tem[0]-1;
        int d = tem[1]-1;
        boolean res = false;
        for (int k = 0 ; k < 2 ; k++){
            if (a[c][k] == tem[1]){
                res = true;
                break;
            }
        }
        for (int k = 0 ; k < 2 ; k++){
            if (a[d][k] == tem[1]){
                res = true;
                break;
            }
        }
        if (res == true) return tem[0];
        else  return tem[1];
    }

    public  static  void  main(String[] args){
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        int[][] list = new int[t][2];
        for (int i = 0 ; i < t ; i++){
            list[i][0] = sc.nextInt();
            list[i][1] = sc.nextInt();
        }
        ArrayList<Integer> arrayList = new ArrayList<Integer>();
        int num = 0;
        for (int i = 0 ; i < t ; i++){

            arrayList.add(find(list,list[num]));
            num = find(list,list[num])-1;
        }
        for (int e : arrayList){
            System.out.print(e+" ");
        }
        System.out.println();
    }
}


import java.util.Scanner;

public class cf {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int a[][] = new int[n + 1][2];

        for (int i = 1; i <= n; i++) {
            a[i][0] = scanner.nextInt();
            a[i][1] = scanner.nextInt();
        }

        System.out.print(1 + " ");
        int counter = 1;
        int current = 1;
        while (counter < n) {
            if (a[a[current][0]][0] == a[current][1] || a[a[current][0]][1] == a[current][1]) {
                System.out.print(a[current][0] + " ");
                System.out.print(a[current][1] + " ");
                current = a[current][1];
            } else{
                System.out.print(a[current][1] + " ");
                System.out.print(a[current][0] + " ");
                current = a[current][0];
            }
            counter += 2;
        }

    }
}


import java.util.Scanner;

public class cf {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int a[][] = new int[n + 1][2];

        for (int i = 1; i <= n; i++) {
            a[i][0] = scanner.nextInt();
            a[i][1] = scanner.nextInt();
        }

        System.out.print(1 + " ");
        int counter = 1;
        int current = 1;
        while (counter < n) {
            if (a[a[current][0]][0] == a[current][1] || a[a[current][0]][1] == a[current][1]) {
                System.out.print(a[current][0] + " ");
//                System.out.print(a[current][1] + " ");
                current = a[current][0];
            } else{
                System.out.print(a[current][1] + " ");
//                System.out.print(a[current][0] + " ");
                current = a[current][1];
            }
            counter += 1;
        }

    }
}


import java.util.Scanner;

public class cf {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int a[][] = new int[n + 1][2];

        for (int i = 1; i <= n; i++) {
            a[i][0] = scanner.nextInt();
            a[i][1] = scanner.nextInt();
        }

        System.out.print(1 + " ");
        int counter = 1;
        int current = 1;
        while (counter < n) {
            if (a[a[current][0]][0] == a[current][1] || a[a[current][0]][1] == a[current][1]) {
                System.out.print(a[current][0] + " ");
                counter++;
                if(counter<n) {
                    System.out.print(a[current][1] + " ");
                    current = a[current][1];
                    counter++;
                }
            } else{
                System.out.print(a[current][1] + " ");
                counter++;
                if(counter<n) {
                    System.out.print(a[current][0] + " ");
                    current = a[current][0];
                    counter++;
                }
            }
        }

    }
}


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Scanner;

@SuppressWarnings("unchecked")
public class C {

	// 22:37-(22:48)
	public static void main(String[] args) throws IOException {
		try (PrintStream out = new PrintStream(new BufferedOutputStream(System.out))) {
			Scanner sc = new Scanner(new BufferedInputStream(System.in));

			int n = sc.nextInt();
			int[][] seqs = new int[2][n];
			for (int i = 0; i < n; i++) {
				seqs[0][i] = sc.nextInt() - 1;
				seqs[1][i] = sc.nextInt() - 1;
			}

			boolean[] used = new boolean[n];

			for (int cnt = 0, i = 0; cnt < n; cnt++) {
				used[i] = true;
				out.print((i + 1) + " ");
				int x = seqs[0][i];
				int y = seqs[1][i];
				i = (seqs[0][x] == y || seqs[1][x] == y) && !used[x] ? x : y;
			}

		}
	}
}


import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Scanner;

@SuppressWarnings("unchecked")
public class C {

	// 22:37-(22:48)
	public static void main(String[] args) throws IOException {
		try (PrintStream out = new PrintStream(new BufferedOutputStream(System.out))) {
			Scanner sc = new Scanner(new BufferedInputStream(System.in));

			int n = sc.nextInt();
			int[][] seqs = new int[2][n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < 2; j++) {
					seqs[j][i] = sc.nextInt() - 1;
				}
			}

			for (int cnt = 0, i = 0; cnt < n; cnt++) {
				out.print((i + 1) + " ");
				int x = seqs[0][i];
				int y = seqs[1][i];
				if (seqs[0][x] == y || seqs[1][x] == y) {
					i = x;
				} else {
					i = y;
				}
			}

		}
	}
}


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

public class MyCode {
  static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

	public static void main (String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try {
      int n = Integer.parseInt(br.readLine());
      int[][] arr = new int[n][2];
      for(int i = 0; i < n; i++) {
        String[] line = br.readLine().split(" ");
        arr[i][0] = Integer.parseInt(line[0])-1;
        arr[i][1] = Integer.parseInt(line[1])-1;
      }

      if(n > 3)
        traverse(0, 0, arr, n);
      else {
        bw.write("1 2 3");
      }
      bw.close();
    } catch (IOException ex) {}
	}

  static void traverse(int i, int counter, int[][] vec, int n) throws IOException {
    if(counter < n) {
      bw.write((i+1) + " ");
      int a = vec[i][0];
      int b = vec[i][1];

      if(vec[a][0] != b && vec[a][1] != b) {
        traverse(b, counter+1, vec, n);
      }
      else {
        traverse(a, counter+1, vec, n);
      }
    }
  }
}


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

public class MyCode {
  static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

	public static void main (String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try {
      int n = Integer.parseInt(br.readLine());
      int[][] arr = new int[n][2];
      for(int i = 0; i < n; i++) {
        String[] line = br.readLine().split(" ");
        arr[i][0] = Integer.parseInt(line[0])-1;
        arr[i][1] = Integer.parseInt(line[1])-1;
      }

      traverse(0, 0, arr, n);
      bw.close();
    } catch (IOException ex) {}
	}

  static void traverse(int i, int counter, int[][] vec, int n) throws IOException {
    if(counter < n) {
      bw.write((i+1) + " ");
      int a = vec[i][0];
      int b = vec[i][1];

      if(vec[a][0] != b && vec[a][1] != b) {
        traverse(b, counter+1, vec, n);
      }
      else {
        traverse(a, counter+1, vec, n);
      }
    }
  }
}


import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.awt.Point;

public class TryB
{

    static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
	 			throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int ni() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nl() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nia(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = ni();
			}
			return a;
		}

		public String rs() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

		static PrintWriter w = new PrintWriter(System.out);
 static char [][]sol;
    public static void main(String[] args)
    {

        InputReader sc = new InputReader(System.in);
        //PrintWriter w = new PrintWriter(System.out);

       /*
        prime  = new boolean[n + 1];
		sieve();
		prime[1] = false;
		*/
		/*
		as = new ArrayList<>();
		for(int i=2;i<=1000000;i++)
		{
		    if(prime[i])
		    as.add(i);
		}
		*/

       /*

	long a = sc.nl();

            BigInteger ans = new BigInteger("1");
            for (long i = 1; i < Math.sqrt(a); i++) {
                if (a % i == 0) {
                    if (a / i == i) {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));

                    } else {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));
                        ans = ans.multiply(BigInteger.valueOf(phi(a / i)));

                    }

                }
            }
            w.println(ans.mod(bigInteger));
            */

         // MergeSort ob = new MergeSort();
       // ob.sort(arr, 0, arr.length-1);

    // Student []st = new Student[x];
   // st[i] = new Student(i,d[i]);
     //Arrays.sort(st,(p,q)->p.diff-q.diff);
     int x = sc.ni();
     ArrayList<Integer> []a = new ArrayList[x+1];
     for(int i=1;i<=x;i++)
     {
         a[i] = new ArrayList<>();
     }
     for(int i=0;i<x;i++)
     {
         int p = sc.ni();
         int q = sc.ni();
         a[i+1].add(p);
         a[i+1].add(q);
     }
     boolean []vis = new boolean[x+1];
     ArrayList<Integer> res = new ArrayList<>();
     int f = 0;
     vis[1] = true;
     res.add(1);
     LinkedList<Integer> l = new LinkedList<>();
     l.add(1);
     while(!l.isEmpty())
     {
         int q = l.removeFirst();
         int t1 = a[q].get(0);
         int t2 = a[q].get(1);
         if(!vis[t1] || !vis[t2])
         {
         if(a[t1].contains(t2))
         {
             res.add(t1);
             res.add(t2);
             vis[t1] = true;
             vis[t2] = true;
             l.add(t2);
         }
         else
         {
             res.add(t2);
             res.add(t1);
             vis[t1] = true;
             vis[t2] = true;
             l.add(t1);
         }
         }

     }
     for(int i=0;i<res.size();i++)
     {
         w.print(res.get(i) + " ");
     }

     w.close();

    }
    /*
     static void dfs(List<Integer>[] graph, int u,int []p1,List<Integer> res) {
      //res = new ArrayList<>();
    vis[u] = true;
    for (int v : graph[u])
      if (!vis[v])
        dfs(graph, v,p1,res);
    res.add(u);
    ts.add(p1[u-1]);

  }
*/
    static int log(long base,long sum)
    {
        long temp = sum;
        int i = 0;
        while(sum > 0)
        {
            sum /= base;
            i++;
        }
        return i;
    }
    static boolean checkT(int a,int b, int c)
    {
        int f = 0;
        if(a+b <= c || b+c <=a||a+c <= b)
            return false;
        else
            return true;
    }
    static double costheta(int a,int b,int c)
    {
        double pos = ((double)b*(double)b + (double)c*(double)c-(double)a*(double)a) / (2*(double)b*(double)c);
         return pos;
    }
     public static int ip(String s){
		return Integer.parseInt(s);
	}
	 public static String ips(int s){
		return Integer.toString(s);
	}
         static long area(int ax,int ay,int bx,int by,int cx,int cy)
         {
             long ar = ((long)ax*((long)by-(long)cy)) + ((long)bx*((long)cy-(long)ay)) + ((long)cx*((long)ay-(long)by));
             return Math.abs(ar);
         }
         public static int lowerBound(Student[] array, int length, int value) {
        int low = 0;
        int high = length-1;
        while (low < high) {
            final int mid = (low + high) / 2;
            if (value <= array[mid].val) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        return low;
  }
  public static int upperBound(int[] array, int length, int value) {
        int low = 0;
        int high = length-1;
        while (low < high) {
            final int mid = (low + high) / 2;
            if (value >= array[mid]) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return low;
    }
   static class Student
    {

        int val;
        int index;
        Student(int val,int index)
        {
            this.val = val;
            this.index = index;

        }

    }
}


import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.awt.Point;

public class TryB
{

    static class InputReader {

		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;

		public InputReader(InputStream st) {
			this.stream = st;
		}

		public int read() {
			if (snumChars == -1)
	 			throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int ni() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nl() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nia(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = ni();
			}
			return a;
		}

		public String rs() {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

		static PrintWriter w = new PrintWriter(System.out);
 static char [][]sol;
    public static void main(String[] args)
    {

        InputReader sc = new InputReader(System.in);
        //PrintWriter w = new PrintWriter(System.out);

       /*
        prime  = new boolean[n + 1];
		sieve();
		prime[1] = false;
		*/
		/*
		as = new ArrayList<>();
		for(int i=2;i<=1000000;i++)
		{
		    if(prime[i])
		    as.add(i);
		}
		*/

       /*

	long a = sc.nl();

            BigInteger ans = new BigInteger("1");
            for (long i = 1; i < Math.sqrt(a); i++) {
                if (a % i == 0) {
                    if (a / i == i) {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));

                    } else {
                        ans = ans.multiply(BigInteger.valueOf(phi(i)));
                        ans = ans.multiply(BigInteger.valueOf(phi(a / i)));

                    }

                }
            }
            w.println(ans.mod(bigInteger));
            */

         // MergeSort ob = new MergeSort();
       // ob.sort(arr, 0, arr.length-1);

    // Student []st = new Student[x];
   // st[i] = new Student(i,d[i]);
     //Arrays.sort(st,(p,q)->p.diff-q.diff);
     int x = sc.ni();
     ArrayList<Integer> []a = new ArrayList[x+1];
     for(int i=1;i<=x;i++)
     {
         a[i] = new ArrayList<>();
     }
     for(int i=0;i<x;i++)
     {
         int p = sc.ni();
         int q = sc.ni();
         a[i+1].add(p);
         a[i+1].add(q);
     }
     boolean []vis = new boolean[x+1];
     ArrayList<Integer> res = new ArrayList<>();
     int f = 0;
     vis[1] = true;
     res.add(1);
     LinkedList<Integer> l = new LinkedList<>();
     l.add(1);
     while(!l.isEmpty())
     {
         int q = l.removeFirst();
         int t1 = a[q].get(0);
         int t2 = a[q].get(1);
         if(!vis[t1] || !vis[t2])
         {
         if(a[t1].contains(t2))
         {
             res.add(t1);
             res.add(t2);
             vis[t1] = true;
             vis[t2] = true;
             l.add(t2);
         }
         else
         {
             res.add(t2);
             res.add(t1);
             vis[t1] = true;
             vis[t2] = true;
             l.add(t1);
         }
         }

     }
     boolean []v1 = new boolean[x+1];
     for(int i=0;i<res.size();i++)
     {
         if(!v1[res.get(i)])
         {
         w.print(res.get(i) + " ");
         }
         v1[res.get(i)] = true;

     }

     w.close();

    }
    /*
     static void dfs(List<Integer>[] graph, int u,int []p1,List<Integer> res) {
      //res = new ArrayList<>();
    vis[u] = true;
    for (int v : graph[u])
      if (!vis[v])
        dfs(graph, v,p1,res);
    res.add(u);
    ts.add(p1[u-1]);

  }
*/
    static int log(long base,long sum)
    {
        long temp = sum;
        int i = 0;
        while(sum > 0)
        {
            sum /= base;
            i++;
        }
        return i;
    }
    static boolean checkT(int a,int b, int c)
    {
        int f = 0;
        if(a+b <= c || b+c <=a||a+c <= b)
            return false;
        else
            return true;
    }
    static double costheta(int a,int b,int c)
    {
        double pos = ((double)b*(double)b + (double)c*(double)c-(double)a*(double)a) / (2*(double)b*(double)c);
         return pos;
    }
     public static int ip(String s){
		return Integer.parseInt(s);
	}
	 public static String ips(int s){
		return Integer.toString(s);
	}
         static long area(int ax,int ay,int bx,int by,int cx,int cy)
         {
             long ar = ((long)ax*((long)by-(long)cy)) + ((long)bx*((long)cy-(long)ay)) + ((long)cx*((long)ay-(long)by));
             return Math.abs(ar);
         }
         public static int lowerBound(Student[] array, int length, int value) {
        int low = 0;
        int high = length-1;
        while (low < high) {
            final int mid = (low + high) / 2;
            if (value <= array[mid].val) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        return low;
  }
  public static int upperBound(int[] array, int length, int value) {
        int low = 0;
        int high = length-1;
        while (low < high) {
            final int mid = (low + high) / 2;
            if (value >= array[mid]) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return low;
    }
   static class Student
    {

        int val;
        int index;
        Student(int val,int index)
        {
            this.val = val;
            this.index = index;

        }

    }
}


import java.util.Scanner;

public class D {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int first1 = 0;
        int first2 = 0;

        int[][] nodes = new int[n+1][2];
        for (int i=0; i<n; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (nodes[a][0] == 0) {
                nodes[a][0] = b;
            } else {
                nodes[a][1] = b;
            }
            if (nodes[b][0] == 0) {
                nodes[b][0] = a;
            } else {
                nodes[b][1] = a;
            }
            if (first1 == 0){
                first1 = a;
                first2 = b;
            }
        }

        int prev = 0;
        int current = 1;
        do {
            System.out.print(current + " ");
            if (nodes[current][0] != prev && (current != 1 || nodes[current][0] == first1 || nodes[current][0] == first2 )) {
                prev = current;
                current = nodes[prev][0];
            } else {
                prev = current;
                current = nodes[prev][1];
            }
        } while (current != 1);
    }
}


import java.util.Scanner;

public class D {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();

        int[][] nodes = new int[n+1][2];
        for (int i=0; i<n; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (nodes[a][0] == 0) {
                nodes[a][0] = b;
            } else {
                nodes[a][1] = b;
            }
            if (nodes[b][0] == 0) {
                nodes[b][0] = a;
            } else {
                nodes[b][1] = a;
            }
        }

        int prev = 0;
        int current = 1;
        do {
            System.out.print(current + " ");
            if (nodes[current][0] != prev) {
                prev = current;
                current = nodes[prev][0];
            } else {
                prev = current;
                current = nodes[prev][1];
            }
        } while (current != 1);
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;
public class R529D {
    public static void main (String[] args) throws java.lang.Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        int n = in.nextInt(), cur = 0;
        int[][] mat = new int[n][2];
        for (int i = 0; i < n; i++) {
            mat[i][0] = in.nextInt() - 1;
            mat[i][1] = in.nextInt() - 1;
        }
        w.print((cur + 1) + " ");
        HashSet<Integer> hs = new HashSet<>();
        hs.add(cur);
        while (true) {
            int temp1 = mat[cur][0], temp2 = mat[cur][1];
            //w.println(temp1 + "--" + temp2);
            if (mat[temp1][0] == temp2 || mat[temp1][1] == temp2) {
                if (!hs.contains(temp1))
                    w.print((temp1 + 1) + " ");
                if (!hs.contains(temp2))
                    w.print((temp2 + 1) + " ");
                cur = temp2;
            } else {
                if (!hs.contains(temp2))
                    w.print((temp2 + 1) + " ");
                if (!hs.contains(temp1))
                    w.print((temp1 + 1) + " ");
                cur = temp1;

            }
            if (hs.contains(temp1) && hs.contains(temp2))
                break;
            hs.add(temp1);
            hs.add(temp2);
        }
        w.close();
    }
    static boolean nextPermutation(int[] a) {
        int n = a.length;
        int ptr = n - 1;
        while (ptr > 0 && a[ptr - 1] >= a[ptr]) {
            ptr--;
        }

        for (int i = ptr, j = n - 1; i < j; i++, j--) {
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }

        if (ptr == 0) {
            return false;
        }

        for (int i = ptr;; i++) {
            if (a[ptr - 1] < a[i]) {
                int tmp = a[ptr - 1];
                a[ptr - 1] = a[i];
                a[i] = tmp;
                return true;
            }
        }
    }
    static int fibo(int n) {
        if (n == 1 || n == 2)
            return 1;
        return fibo(n - 1) + fibo(n - 2);
    }
    /*static int fibo(int n) {
        if (n == 0)
            return 0;
        if (n == 1 || n == 2)
            return f[n] = 1;
        if (f[n] != 0)
            return f[n];
        if (n % 2 == 0) {
            int k = (n) / 2;
            return f[n] = (fibo(k - 1) * 2 + fibo(k)) * fibo(k);
        } else {
            int k = (n + 1) / 2;
            return f[n] = fibo(k - 1) * fibo(k - 1) + fibo(k) * fibo(k);
        }
    }*/
    static class Edge implements Comparable<Edge> {
        int from, to, cost;
        Edge(int from, int to, int cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }
        public int compareTo(Edge O) {
            return this.cost - O.cost;
        }
    }
    static String swap(String s, int i, int j) {
        char[] ca = s.toCharArray();
        char temp = ca[i];
        ca[i] = ca[j];
        ca[j] = temp;
        return new String(ca);
    }
    static void findMissExtra(int[] a) {
        HashSet<Integer> hs = new HashSet<>();
        int n = a.length, extra = 0, miss = 0;
        for (int i = 0; i < n; i++) {
            if (hs.contains(a[i]))
                extra = a[i];
            hs.add(a[i]);

        }
        for (int i = 1; i <= n; i++) {
            if (!hs.contains(i)) {
                miss = i;
                break;
            }
        }
        System.out.println(miss + ", " + extra);
    }
    static void find(int m, int s) {
        if (s == 0 || s > m * 9) {
            System.out.println("Impossible");
            return ;
        }
        s -= 1;
        int[] num = new int[m];
        for (int i = m - 1; i > 0; i--) {
            int temp = Math.min(s, 9);
            num[i] = temp;
            s -= temp;
        }
        num[0] += s + 1;
        for (int x : num)
            System.out.print(x);
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }

        public void skip(int x) {
            while (x-- > 0)
                read();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public String nextString() {
            return next();
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        public String nextLine() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
        public boolean hasNext() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value != -1;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}


import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;
public class R529D {
    public static void main (String[] args) throws java.lang.Exception {
        InputReader in = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        int n = in.nextInt();
        int[][] mat = new int[n][2];
        for (int i = 0; i < n; i++) {
            mat[i][0] = in.nextInt() - 1;
            mat[i][1] = in.nextInt() - 1;
        }
        int i = 1, cur = 0;
        w.print((cur + 1) + " ");
        while (i < n) {
            int temp1 = mat[cur][0], temp2 = mat[cur][1];
            //w.println(temp1 + "--" + temp2);
            if (mat[temp1][0] == temp2 || mat[temp1][1] == temp2) {
                w.print((temp1 + 1) + " " + (temp2 + 1) + " ");
                cur = temp2;
            } else {
                w.print((temp2 + 1) + " " + (temp1 + 1) + " ");
                cur = temp1;

            }
            i += 2;
        }
        w.close();
    }
    static boolean nextPermutation(int[] a) {
        int n = a.length;
        int ptr = n - 1;
        while (ptr > 0 && a[ptr - 1] >= a[ptr]) {
            ptr--;
        }

        for (int i = ptr, j = n - 1; i < j; i++, j--) {
            int tmp = a[i];
            a[i] = a[j];
            a[j] = tmp;
        }

        if (ptr == 0) {
            return false;
        }

        for (int i = ptr;; i++) {
            if (a[ptr - 1] < a[i]) {
                int tmp = a[ptr - 1];
                a[ptr - 1] = a[i];
                a[i] = tmp;
                return true;
            }
        }
    }
    static int fibo(int n) {
        if (n == 1 || n == 2)
            return 1;
        return fibo(n - 1) + fibo(n - 2);
    }
    /*static int fibo(int n) {
        if (n == 0)
            return 0;
        if (n == 1 || n == 2)
            return f[n] = 1;
        if (f[n] != 0)
            return f[n];
        if (n % 2 == 0) {
            int k = (n) / 2;
            return f[n] = (fibo(k - 1) * 2 + fibo(k)) * fibo(k);
        } else {
            int k = (n + 1) / 2;
            return f[n] = fibo(k - 1) * fibo(k - 1) + fibo(k) * fibo(k);
        }
    }*/
    static class Edge implements Comparable<Edge> {
        int from, to, cost;
        Edge(int from, int to, int cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }
        public int compareTo(Edge O) {
            return this.cost - O.cost;
        }
    }
    static String swap(String s, int i, int j) {
        char[] ca = s.toCharArray();
        char temp = ca[i];
        ca[i] = ca[j];
        ca[j] = temp;
        return new String(ca);
    }
    static void findMissExtra(int[] a) {
        HashSet<Integer> hs = new HashSet<>();
        int n = a.length, extra = 0, miss = 0;
        for (int i = 0; i < n; i++) {
            if (hs.contains(a[i]))
                extra = a[i];
            hs.add(a[i]);

        }
        for (int i = 1; i <= n; i++) {
            if (!hs.contains(i)) {
                miss = i;
                break;
            }
        }
        System.out.println(miss + ", " + extra);
    }
    static void find(int m, int s) {
        if (s == 0 || s > m * 9) {
            System.out.println("Impossible");
            return ;
        }
        s -= 1;
        int[] num = new int[m];
        for (int i = m - 1; i > 0; i--) {
            int temp = Math.min(s, 9);
            num[i] = temp;
            s -= temp;
        }
        num[0] += s + 1;
        for (int x : num)
            System.out.print(x);
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }

        public void skip(int x) {
            while (x-- > 0)
                read();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public String nextString() {
            return next();
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        public String nextLine() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
        public boolean hasNext() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value != -1;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class c {

	public static class Pair
	{
		int p1,p2;
		Pair(int p1,int p2)
		{
			this.p1 = p1;
			this.p2 = p2;
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		FastReader s = new FastReader();

		int N = s.nextInt();
		Pair[] pair = new Pair[N+1];
		HashSet<Integer> set = new HashSet<>();
		set.add(1);
		for(int i=1;i<=N;i++)
		{
			int x = s.nextInt();
			int y = s.nextInt();

			pair[i] = new Pair(x,y);
		}

		int[] ans = new int[N+1];
		ans[1] = 1;
		for(int i=1;i<N;i++)
		{
			int p1 = pair[ans[i]].p1;
			int p2 = pair[ans[i]].p2;

			int p = p1;
			if((pair[p2].p1 == p1||pair[p2].p2==p1)&&!set.contains(p2)) {
				p = p2;
			}

			ans[i+1] = p;
			set.add(p);
		}

		for(int i=1;i<=N;i++)
			System.out.print(ans[i]+" ");
	}

	public static void printAns(PriorityQueue<Integer> pq)
	{
		if(pq.isEmpty())
			return;
		else
		{
			int val = pq.remove();
			printAns(pq);
			System.out.print(val+" ");
		}
	}

	public static class MyComparator implements Comparator<Integer>
	{
		@Override
		public int compare(Integer arg0, Integer arg1) {
			// TODO Auto-generated method stub
			return arg1-arg0;
		}
	}

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class c {

	public static class Pair
	{
		int p1,p2;
		Pair(int p1,int p2)
		{
			this.p1 = p1;
			this.p2 = p2;
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		FastReader s = new FastReader();

		int N = s.nextInt();
		Pair[] pair = new Pair[N+1];

		for(int i=1;i<=N;i++)
		{
			int x = s.nextInt();
			int y = s.nextInt();

			pair[i] = new Pair(x,y);
		}

		int[] ans = new int[N+1];
		ans[1] = 1;
		for(int i=1;i<N;i++)
		{
			int p1 = pair[ans[i]].p1;
			int p2 = pair[ans[i]].p2;

			int p = p1;
			if(pair[p2].p1==p1||pair[p2].p2 == p1)
				p = p2;
			ans[i+1] = p;
		}

		for(int i=1;i<=N;i++)
			System.out.print(ans[i]+" ");
	}

	public static void printAns(PriorityQueue<Integer> pq)
	{
		if(pq.isEmpty())
			return;
		else
		{
			int val = pq.remove();
			printAns(pq);
			System.out.print(val+" ");
		}
	}

	public static class MyComparator implements Comparator<Integer>
	{
		@Override
		public int compare(Integer arg0, Integer arg1) {
			// TODO Auto-generated method stub
			return arg1-arg0;
		}
	}

	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

}


import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;
import static java.lang.Math.abs;
import static java.lang.Math.min;
import static java.lang.Math.max;
import static java.lang.Math.sqrt;
import static java.lang.Integer.signum;

@SuppressWarnings("unchecked")
public class P1095D {

  public void run() throws Exception {
    int n = nextInt(), f [] = new int [n], s [] = new int [n], a [] = new int [n];
    for (int i = 0; i < n; f[i] = nextInt() - 1, s[i] = nextInt() - 1, i++);

    boolean [] u = new boolean [n];
    for (int i = 0, k = 0; k < n; k++) {
      a[k] = i + 1;
      u[i] = true;
      int fi = f[i], si = s[i];
      i = (((f[fi] == si) || (s[fi] == si)) && (!u[fi])) ? fi : si;
    }

    IntStream.of(a).forEach(this::println);
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P1095D().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }

  int gcd(int a, int b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Integer.numberOfTrailingZeros(a), bz = Integer.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Integer.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Integer.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  long gcd(long a, long b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Long.numberOfTrailingZeros(a), bz = Long.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Long.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Long.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  void shuffle(int [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      int t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void shuffle(long [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      long t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void shuffle(Object [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      Object t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void flush() {
    pw.flush();
  }

  void pause() {
    flush();
    System.console().readLine();
  }
}


import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;
import static java.lang.Math.abs;
import static java.lang.Math.min;
import static java.lang.Math.max;
import static java.lang.Math.sqrt;
import static java.lang.Integer.signum;

@SuppressWarnings("unchecked")
public class P1095D {

  public void run() throws Exception {
    int n = nextInt(), f [] = new int [n], s [] = new int [n], a [] = new int [n];
    for (int i = 0; i < n; f[i] = nextInt() - 1, s[i] = nextInt() - 1, i++);

    if (n == 3) {
      println("1 2 3");
      return;
    }

    for (int i = 0, k = 0; k < n; k++) {
      a[k] = i + 1;
      int fi = f[i], si = s[i];
      i = ((f[fi] == si) || (s[fi] == si)) ? fi : si;
    }

    IntStream.of(a).forEach(this::println);
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P1095D().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }

  int gcd(int a, int b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Integer.numberOfTrailingZeros(a), bz = Integer.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Integer.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Integer.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  long gcd(long a, long b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Long.numberOfTrailingZeros(a), bz = Long.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Long.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Long.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  void shuffle(int [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      int t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void shuffle(long [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      long t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void shuffle(Object [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      Object t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void flush() {
    pw.flush();
  }

  void pause() {
    flush();
    System.console().readLine();
  }
}


import java.io.*;
import java.math.*;
import java.util.*;
import java.util.stream.*;
import static java.lang.Math.abs;
import static java.lang.Math.min;
import static java.lang.Math.max;
import static java.lang.Math.sqrt;
import static java.lang.Integer.signum;

@SuppressWarnings("unchecked")
public class P1095D {

  public void run() throws Exception {
    int n = nextInt(), f [] = new int [n], s [] = new int [n], a [] = new int [n];
    for (int i = 0; i < n; f[i] = nextInt() - 1, s[i] = nextInt() - 1, i++);

    for (int i = 0, k = 0; k < n; k++) {
      a[k] = i + 1;
      int fi = f[i], si = s[i];
      i = ((f[fi] == si) || (s[fi] == si)) ? fi : si;
    }

    IntStream.of(a).forEach(this::println);
  }

  public static void main(String... args) throws Exception {
    br = new BufferedReader(new InputStreamReader(System.in));
    pw = new PrintWriter(new BufferedOutputStream(System.out));
    new P1095D().run();
    br.close();
    pw.close();
    System.err.println("\n[Time : " + (System.currentTimeMillis() - startTime) + " ms]");
  }

  static long startTime = System.currentTimeMillis();
  static BufferedReader br;
  static PrintWriter pw;
  StringTokenizer stok;

  String nextToken() throws IOException {
    while (stok == null || !stok.hasMoreTokens()) {
      String s = br.readLine();
      if (s == null) { return null; }
      stok = new StringTokenizer(s);
    }
    return stok.nextToken();
  }

  void print(byte b) { print("" + b); }
  void print(int i) { print("" + i); }
  void print(long l) { print("" + l); }
  void print(double d) { print("" + d); }
  void print(char c) { print("" + c); }
  void print(Object o) {
    if (o instanceof int[]) { print(Arrays.toString((int [])o));
    } else if (o instanceof long[]) { print(Arrays.toString((long [])o));
    } else if (o instanceof char[]) { print(Arrays.toString((char [])o));
    } else if (o instanceof byte[]) { print(Arrays.toString((byte [])o));
    } else if (o instanceof short[]) { print(Arrays.toString((short [])o));
    } else if (o instanceof boolean[]) { print(Arrays.toString((boolean [])o));
    } else if (o instanceof float[]) { print(Arrays.toString((float [])o));
    } else if (o instanceof double[]) { print(Arrays.toString((double [])o));
    } else if (o instanceof Object[]) { print(Arrays.toString((Object [])o));
    } else { print("" + o); }
  }
  void print(String s) { pw.print(s); }
  void println() { println(""); }
  void println(byte b) { println("" + b); }
  void println(int i) { println("" + i); }
  void println(long l) { println("" + l); }
  void println(double d) { println("" + d); }
  void println(char c) { println("" + c); }
  void println(Object o) { print(o); println(); }
  void println(String s) { pw.println(s); }
  int nextInt() throws IOException { return Integer.parseInt(nextToken()); }
  long nextLong() throws IOException { return Long.parseLong(nextToken()); }
  double nextDouble() throws IOException { return Double.parseDouble(nextToken()); }
  char nextChar() throws IOException { return (char) (br.read()); }
  String next() throws IOException { return nextToken(); }
  String nextLine() throws IOException { return br.readLine(); }
  int [] readInt(int size) throws IOException {
    int [] array = new int [size];
    for (int i = 0; i < size; i++) { array[i] = nextInt(); }
    return array;
  }
  long [] readLong(int size) throws IOException {
    long [] array = new long [size];
    for (int i = 0; i < size; i++) { array[i] = nextLong(); }
    return array;
  }
  double [] readDouble(int size) throws IOException {
    double [] array = new double [size];
    for (int i = 0; i < size; i++) { array[i] = nextDouble(); }
    return array;
  }
  String [] readLines(int size) throws IOException {
    String [] array = new String [size];
    for (int i = 0; i < size; i++) { array[i] = nextLine(); }
    return array;
  }

  int gcd(int a, int b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Integer.numberOfTrailingZeros(a), bz = Integer.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Integer.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Integer.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  long gcd(long a, long b) {
    if (a == 0) return Math.abs(b); if (b == 0) return Math.abs(a);
    a = Math.abs(a); b = Math.abs(b);
    int az = Long.numberOfTrailingZeros(a), bz = Long.numberOfTrailingZeros(b);
    a >>>= az; b >>>= bz;
    while (a != b) {
      if (a > b) { a -= b; a >>>= Long.numberOfTrailingZeros(a); }
            else { b -= a; b >>>= Long.numberOfTrailingZeros(b); }
    }
    return (a << Math.min(az, bz));
  }

  void shuffle(int [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      int t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void shuffle(long [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      long t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void shuffle(Object [] a) {
    Random r = new Random();
    for (int i = a.length - 1; i >= 0; i--) {
      int j = r.nextInt(a.length);
      Object t = a[i]; a[i] = a[j]; a[j] = t;
    }
  }

  void flush() {
    pw.flush();
  }

  void pause() {
    flush();
    System.console().readLine();
  }
}


import java.util.*;
import java.io.*;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int n=Integer.parseInt(br.readLine());
            int a[][]=new int[n+1][2];
            for(int i=1;i<=n;i++)
            {
                  String s1[]=br.readLine().split(" ");
                  a[i][0]=Integer.parseInt(s1[0]);
                  a[i][1]=Integer.parseInt(s1[1]);
            }

            for(int i=1;i<=n;i++)
            {
                  int x=a[i][0];
                  int y=a[i][1];
                  if(a[y][0]==x || a[y][1]==x)
                  { a[i][0]=y; a[i][1]=x; }
                 // System.out.println(a[i][0]+" "+a[i][1]);
            }

            StringBuffer sb=new StringBuffer();
            sb.append("1 ");
            int u=a[1][0];
            while(u!=1)
            {
                  sb.append(u).append(" ");
                  u=a[u][0];
            }

            if(n==3)
             System.out.println("1 2 3");
            else
            System.out.println(sb);
      }
}


import java.util.*;
import java.io.*;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            int n=Integer.parseInt(br.readLine());
            int a[][]=new int[n+1][2];
            for(int i=1;i<=n;i++)
            {
                  String s1[]=br.readLine().split(" ");
                  a[i][0]=Integer.parseInt(s1[0]);
                  a[i][1]=Integer.parseInt(s1[1]);
            }

            for(int i=1;i<=n;i++)
            {
                  int x=a[i][0];
                  int y=a[i][1];
                  if(a[y][0]==x || a[y][1]==x)
                  { a[i][0]=y; a[i][1]=x; }
                 // System.out.println(a[i][0]+" "+a[i][1]);
            }

            StringBuffer sb=new StringBuffer();
            sb.append("1 ");
            int u=a[1][0];
            while(u!=1)
            {
                  sb.append(u).append(" ");
                  u=a[u][0];
            }

            System.out.println(sb);
      }
}