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]);
            }

            ArrayList<Integer> al=new ArrayList<Integer>();
            al.add(1);
            int u=a[1][0];
            while(u!=1)
            {
                  al.add(u);
                  u=a[u][0];
            }

            if(n==3)
             System.out.println("1 2 3");
            else
            {
            for(int i=0;i<n;i++)
            System.out.print(al.get(i)+" ");
            }
      }
}


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]);
            }

            if(n==3)
             System.out.println("1 2 3");
            else
            {
            System.out.print("1 ");
            int u=a[1][0];
            while(u!=1)
            {
                  System.out.print(u+" ");
                  u=a[u][0];
            }
            }
      }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static class Task {

		final int NN = 200005;
		final int MOD = 1000000007;
		final int INF = 2000000000;
		final long INFINITY = 1000000000000000000L;

		public void solve(InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int [][] a = new int[n][2];
			int [] next = new int[n];
			for(int i=0;i<n;++i)
				next[i] = -1;
			for(int i=0;i<n;++i) {
				a[i][0] = in.nextInt();--a[i][0];
				a[i][1] = in.nextInt();--a[i][1];
			}
			for(int i=0;i<n;++i) {
				int x = a[i][0], y = a[i][1];
				if(a[x][0] == y || a[x][1] == y) {
					if(next[i] == -1) {
						next[i] = x;
					}
					if(next[x] == -1) {
						next[x] = y;
					}
				} else {
					next[i] = y;next[y] = x;
				}
			}
			int cur = 0;
			do {
				out.print(cur + 1 + " ");
				cur = next[cur];
			}while(cur != 0);
			out.println("");
		}

	}

	static void prepareIO(boolean isFileIO) {
		Task solver = new Task();
		// Standard IO
		if(!isFileIO) {
			InputStream inputStream = System.in;
	        OutputStream outputStream = System.out;
	        InputReader in = new InputReader(inputStream);
	        PrintWriter out = new PrintWriter(outputStream);
	        solver.solve(in, out);
	        out.close();
		}
        // File IO
		else {
			String IPfilePath = System.getProperty("user.home") + "/Downloads/ip.in";
	        String OPfilePath = System.getProperty("user.home") + "/Downloads/op.out";
	        InputReader fin = new InputReader(IPfilePath);
	        PrintWriter fout = null;
	        try {
				fout = new PrintWriter(new File(OPfilePath));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
	        solver.solve(fin, fout);
	        fout.close();
		}
	}

	public static void main(String[] args) {
        prepareIO(false);
	}

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public InputReader(String filePath) {
        	File file = new File(filePath);
            try {
				reader = new BufferedReader(new FileReader(file));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
            tokenizer = null;
        }

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

	static class Task {

		int NN = 200005;
		int MOD = 1000000007;
		int INF = 2000000000;

		public void solve(InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int [][] a = new int[n][2];
			int [] next = new int[n];
			for(int i=0;i<n;++i) {
				a[i][0] = in.nextInt();--a[i][0];
				a[i][1] = in.nextInt();--a[i][1];
			}
			for(int i=0;i<n;++i) {
				int x = a[i][0], y = a[i][1];
				if(a[x][0] == y || a[x][1] == y) {
					next[i] = x;next[x] = y;
				} else {
					next[i] = y;next[y] = x;
				}
			}
			int cur = 0;
			do {
				out.print(cur + 1 + " ");
				cur = next[cur];
			}while(cur != 0);
			out.println("");
		}

	}

	static void prepareIO(boolean isFileIO) {
		Task solver = new Task();
		// Standard IO
		if(!isFileIO) {
			InputStream inputStream = System.in;
	        OutputStream outputStream = System.out;
	        InputReader in = new InputReader(inputStream);
	        PrintWriter out = new PrintWriter(outputStream);
	        solver.solve(in, out);
	        out.close();
		}
        // File IO
		else {
			String IPfilePath = System.getProperty("user.home") + "/Downloads/ip.in";
	        String OPfilePath = System.getProperty("user.home") + "/Downloads/op.out";
	        InputReader fin = new InputReader(IPfilePath);
	        PrintWriter fout = null;
	        try {
				fout = new PrintWriter(new File(OPfilePath));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
	        solver.solve(fin, fout);
	        fout.close();
		}
	}

	public static void main(String[] args) {
        prepareIO(false);
	}

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public InputReader(String filePath) {
        	File file = new File(filePath);
            try {
				reader = new BufferedReader(new FileReader(file));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            tokenizer = null;
        }

        public String nextLine() {
        	String str = "";
        	try {
				str = reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        	return str;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static class Task {

		final int NN = 200005;
		final int MOD = 1000000007;
		final int INF = 2000000000;
		final long INFINITY = 1000000000000000000L;

		public void solve(InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int [][] a = new int[n][2];
			int [] next = new int[n];
			for(int i=0;i<n;++i)
				next[i] = -1;
			for(int i=0;i<n;++i) {
				a[i][0] = in.nextInt();--a[i][0];
				a[i][1] = in.nextInt();--a[i][1];
			}
			for(int i=0;i<n;++i) {
				int x = a[i][0], y = a[i][1];
				if(a[x][0] == y || a[x][1] == y) {
					if(next[i] == -1) {
						next[i] = x;
					}
					if(next[x] == -1) {
						next[x] = y;
					}
				} else {
					next[i] = y;next[y] = x;
				}
			}
			boolean [] vis = new boolean[n];
			int cur = 0;
			while(!vis[cur]) {
				out.print(cur + 1 + " ");
				vis[cur] = true;
				cur = next[cur];
			}
			out.println("");
		}

	}

	static void prepareIO(boolean isFileIO) {
		Task solver = new Task();
		// Standard IO
		if(!isFileIO) {
			InputStream inputStream = System.in;
	        OutputStream outputStream = System.out;
	        InputReader in = new InputReader(inputStream);
	        PrintWriter out = new PrintWriter(outputStream);
	        solver.solve(in, out);
	        out.close();
		}
        // File IO
		else {
			String IPfilePath = System.getProperty("user.home") + "/Downloads/ip.in";
	        String OPfilePath = System.getProperty("user.home") + "/Downloads/op.out";
	        InputReader fin = new InputReader(IPfilePath);
	        PrintWriter fout = null;
	        try {
				fout = new PrintWriter(new File(OPfilePath));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
	        solver.solve(fin, fout);
	        fout.close();
		}
	}

	public static void main(String[] args) {
        prepareIO(false);
	}

	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public InputReader(String filePath) {
        	File file = new File(filePath);
            try {
				reader = new BufferedReader(new FileReader(file));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
            tokenizer = null;
        }

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

}


import java.awt.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    public static void dfs(ArrayList<ArrayList<Integer>> array, boolean[] visited, int i){
        if(!visited[i]){
            System.out.print(i + " ");
            visited[i] = true;
            for (int j = 0; j < array.get(i).size(); j++) {
                dfs(array, visited, array.get(i).get(j));
            }
        }

    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<ArrayList<Integer>> array = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            array.add(new ArrayList<>());
        }

        for (int i = 0; i < n; i++) {
            int from = scanner.nextInt();
            int to = scanner.nextInt();
            array.get(to).add(from);
            array.get(from).add(to);
        }
        dfs(array, new boolean[n + 1], 1);

    }
}


import java.awt.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    public static void dfs(ArrayList<ArrayList<Integer>> array, boolean[] visited, int i, ArrayList<Integer> res){
        if(!visited[i]){
            res.add(i);
            visited[i] = true;
            for (int j = 0; j < array.get(i).size(); j++) {
                dfs(array, visited, array.get(i).get(j), res);
            }
        }

    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<ArrayList<Integer>> array = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            array.add(new ArrayList<>());
        }

        int f = -1, s = -1;
        for (int i = 0; i < n; i++) {
            int from = scanner.nextInt();
            int to = scanner.nextInt();
            if(i == 0){
                f = from;
                s = to;
            }
            array.get(to).add(from);
            array.get(from).add(to);
        }
        ArrayList<Integer> result = new ArrayList<>();

        dfs(array, new boolean[n + 1], 1, result);

        if(result.get(1).equals(f) || result.get(1).equals(s)) {
            for (int i = 0; i < result.size(); i++) {
                System.out.print(result.get(i) + " ");
            }
        } else {
            for (int i = result.size() - 1; i >= 0; i--) {
                System.out.print(result.get(i) + " ");
            }
        }

    }
}


import java.awt.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    public static void dfs(ArrayList<ArrayList<Integer>> array, boolean[] visited, int i, ArrayList<Integer> res){
        if(!visited[i]){
            res.add(i);
            visited[i] = true;
            for (int j = 0; j < array.get(i).size(); j++) {
                dfs(array, visited, array.get(i).get(j), res);
            }
        }

    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<ArrayList<Integer>> array = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            array.add(new ArrayList<>());
        }

        for (int i = 0; i < n; i++) {
            int from = scanner.nextInt();
            int to = scanner.nextInt();
            array.get(to).add(from);
            array.get(from).add(to);
        }
        ArrayList<Integer> result = new ArrayList<>();

        dfs(array, new boolean[n + 1], 1, result);

        if(result.get(1).equals(array.get(1).get(0)) || result.get(1).equals(array.get(1).get(1))) {
            for (int i = 0; i < result.size(); i++) {
                System.out.print(result.get(i) + " ");
            }
        } else {
            for (int i = result.size() - 1; i >= 0; i--) {
                System.out.print(result.get(i) + " ");
            }
        }

    }
}


import java.util.*;
import java.io.*;
import javafx.util.Pair;
import java.math.BigInteger;
import java.text.*;
public class cf2 {
    static long mod = (long)1e9 + 7;
    static long mod1 = 998244353;
    static FastScanner f;
    static PrintWriter pw = new PrintWriter(System.out);
    static BufferedReader br;
    static Scanner S = new Scanner(System.in);
    static int inf = (int)(1e6) + 5;
    static long x0; static long y0;
    static void solve()throws IOException {
        int n = f.ni();
        int ans[][] = new int[n + 5][4];
        for (int i = 1; i <= n; ++i) {
            ans[i][1] = f.ni();
            ans[i][2] = f.ni();
        }
        ArrayList<Integer> perm = new ArrayList<>();
        perm.add(1);
        int curr = 1;
        for (int i = 1; perm.size() < n; ++i) {
            int c1 = ans[curr][1];
            int c2 = ans[curr][2];

            // check for curr c1 c2
            if (ans[c1][1] == c2 || ans[c1][2] == c2) {
                perm.add(c1);
                perm.add(c2);
                curr = c2;
            }

            else {
                perm.add(c2);
                perm.add(c1);
                curr = c1;
            }
        }
        for (Integer i : perm) p(i + " ");
    }
    public static void main(String[] args)throws IOException {
        init();
        int t = 1;
        while(t --> 0) {solve();}
        pw.flush();
        pw.close();
    }

/******************************END OF MAIN PROGRAM*******************************************/
    public static void init()throws IOException{if(System.getProperty("ONLINE_JUDGE")==null){f=new FastScanner("");}else{f=new FastScanner(System.in);}}
    public static class FastScanner {
        BufferedReader br;StringTokenizer st;
        FastScanner(InputStream stream){try{br=new BufferedReader(new InputStreamReader(stream));}catch(Exception e){e.printStackTrace();}}
        FastScanner(String str){try{br=new BufferedReader(new FileReader("!a.txt"));}catch(Exception e){e.printStackTrace();}}
        String next(){while(st==null||!st.hasMoreTokens()){try{st=new StringTokenizer(br.readLine());}catch(IOException e){e.printStackTrace();}}return st.nextToken();}
        String nextLine()throws IOException{return br.readLine();}int ni(){return Integer.parseInt(next());}long nl(){return Long.parseLong(next());}double nd(){return Double.parseDouble(next());}
    }
    public static void pn(Object o){pw.println(o);}
    public static void p(Object o){pw.print(o);}
    public static void pni(Object o){pw.println(o);pw.flush();}
    static int gcd(int a,int b){if(b==0)return a;else{return gcd(b,a%b);}}
    static long lcm(long a,long b){return (a*b/gcd(a,b));}
    static long gcd(long a,long b){if(b==0)return a;else{return gcd(b,a%b);}}
    static long exgcd(long a,long b){if(b==0){x0=1;y0=0;return a;}long temp=exgcd(b,a%b);long t=x0;x0=y0;y0=t-a/b*y0;return temp;}
    static long pow(long a,long b){long res=1;while(b>0){if((b&1)==1)res=res*a;b>>=1;a=a*a;}return res;}
    static long mpow(long a,long b){long res=1;while(b>0){if((b&1)==1)res=((res%mod)*(a%mod))%mod;b>>=1;a=((a%mod)*(a%mod))%mod;}return res;}
    static long mul(long a , long b){return ((a%mod)*(b%mod)%mod);}
    static long adp(long a , long b){return ((a%mod)+(b%mod)%mod);}
    static boolean isPrime(long n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(long i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
    static boolean isPrime(int n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(int i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
    static HashSet<Long> factors(long n){HashSet<Long> hs=new HashSet<Long>();for(long i=1;i<=(long)Math.sqrt(n);i++){if(n%i==0){hs.add(i);hs.add(n/i);}}return hs;}
    static HashSet<Integer> factors(int n){HashSet<Integer> hs=new HashSet<Integer>();for(int i=1;i<=(int)Math.sqrt(n);i++){if(n%i==0){hs.add(i);hs.add(n/i);}}return hs;}
    static HashSet<Long> pf(long n){HashSet<Long> ff=factors(n);HashSet<Long> ans=new HashSet<Long>();for(Long i:ff)if(isPrime(i))ans.add(i);return ans;}
    static HashSet<Integer> pf(int n){HashSet<Integer> ff=factors(n);HashSet<Integer> ans=new HashSet<Integer>();for(Integer i:ff)if(isPrime(i))ans.add(i);return ans;}
    static int[] inpint(int n){int arr[]=new int[n];for(int i=0;i<n;i++){arr[i]=f.ni();}return arr;}
    static long[] inplong(int n){long arr[] = new long[n];for(int i=0;i<n;i++){arr[i]=f.nl();}return arr;}
    static boolean ise(int x){return ((x&1)==0);}static boolean ise(long x){return ((x&1)==0);}
    static int gnv(char c){return Character.getNumericValue(c);}
    static int upperbound(ArrayList<Integer> a,int i){int lo=0,hi=a.size()-1,mid=0;int count=0;while(lo<=hi){mid=(lo+hi)/2;if(a.get(mid)<=i){count=mid+1;lo=mid+1;}else hi=mid-1;}return count;}
    static int log(long x){return x==1?0:(1+log(x/2));} static int log(int x){return x==1?0:(1+log(x/2));}
    static void sort(int[] a){ArrayList<Integer> l=new ArrayList<>();for(int i:a)l.add(i);Collections.sort(l);for(int i=0;i<a.length;++i)a[i]=l.get(i);}
    static void sort(long[] a){ArrayList<Long> l=new ArrayList<>();for(long i:a)l.add(i);Collections.sort(l);for(int i=0;i<a.length;++i)a[i]=l.get(i);}
    static void sort(ArrayList<Integer> a){Collections.sort(a);}
}


import java.util.*;
import java.io.*;
import javafx.util.Pair;
import java.math.BigInteger;
import java.text.*;
public class cf2 {
    static long mod = (long)1e9 + 7;
    static long mod1 = 998244353;
    static FastScanner f;
    static PrintWriter pw = new PrintWriter(System.out);
    static BufferedReader br;
    static Scanner S = new Scanner(System.in);
    static int inf = (int)(1e6) + 5;
    static long x0; static long y0;
    static void solve()throws IOException {
        int n = f.ni();
        int ans[][] = new int[n + 5][4];
        for (int i = 1; i <= n; ++i) {
            ans[i][1] = f.ni();
            ans[i][2] = f.ni();
        }
        ArrayList<Integer> perm = new ArrayList<>();
        perm.add(1);
        HashSet<Integer> used = new HashSet<>();
        used.add(1);
        int curr = 1;
        for (int i = 1; perm.size() < n; ++i) {
            int c1 = ans[curr][1];
            int c2 = ans[curr][2];

            // check for curr c1 c2
            if (ans[c1][1] == c2 || ans[c1][2] == c2) {
                if (!used.contains(c1)) perm.add(c1);
                if (!used.contains(c2)) perm.add(c2);
                curr = c2;
                used.add(c1);
                used.add(c2);
            }

            else {
                if (!used.contains(c2)) perm.add(c2);
                if (!used.contains(c1)) perm.add(c1);
                curr = c1;
                used.add(c1);
                used.add(c2);
            }
        }
        for (Integer i : perm) p(i + " ");
    }
    public static void main(String[] args)throws IOException {
        init();
        int t = 1;
        while(t --> 0) {solve();}
        pw.flush();
        pw.close();
    }

/******************************END OF MAIN PROGRAM*******************************************/
    public static void init()throws IOException{if(System.getProperty("ONLINE_JUDGE")==null){f=new FastScanner("");}else{f=new FastScanner(System.in);}}
    public static class FastScanner {
        BufferedReader br;StringTokenizer st;
        FastScanner(InputStream stream){try{br=new BufferedReader(new InputStreamReader(stream));}catch(Exception e){e.printStackTrace();}}
        FastScanner(String str){try{br=new BufferedReader(new FileReader("!a.txt"));}catch(Exception e){e.printStackTrace();}}
        String next(){while(st==null||!st.hasMoreTokens()){try{st=new StringTokenizer(br.readLine());}catch(IOException e){e.printStackTrace();}}return st.nextToken();}
        String nextLine()throws IOException{return br.readLine();}int ni(){return Integer.parseInt(next());}long nl(){return Long.parseLong(next());}double nd(){return Double.parseDouble(next());}
    }
    public static void pn(Object o){pw.println(o);}
    public static void p(Object o){pw.print(o);}
    public static void pni(Object o){pw.println(o);pw.flush();}
    static int gcd(int a,int b){if(b==0)return a;else{return gcd(b,a%b);}}
    static long lcm(long a,long b){return (a*b/gcd(a,b));}
    static long gcd(long a,long b){if(b==0)return a;else{return gcd(b,a%b);}}
    static long exgcd(long a,long b){if(b==0){x0=1;y0=0;return a;}long temp=exgcd(b,a%b);long t=x0;x0=y0;y0=t-a/b*y0;return temp;}
    static long pow(long a,long b){long res=1;while(b>0){if((b&1)==1)res=res*a;b>>=1;a=a*a;}return res;}
    static long mpow(long a,long b){long res=1;while(b>0){if((b&1)==1)res=((res%mod)*(a%mod))%mod;b>>=1;a=((a%mod)*(a%mod))%mod;}return res;}
    static long mul(long a , long b){return ((a%mod)*(b%mod)%mod);}
    static long adp(long a , long b){return ((a%mod)+(b%mod)%mod);}
    static boolean isPrime(long n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(long i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
    static boolean isPrime(int n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(int i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
    static HashSet<Long> factors(long n){HashSet<Long> hs=new HashSet<Long>();for(long i=1;i<=(long)Math.sqrt(n);i++){if(n%i==0){hs.add(i);hs.add(n/i);}}return hs;}
    static HashSet<Integer> factors(int n){HashSet<Integer> hs=new HashSet<Integer>();for(int i=1;i<=(int)Math.sqrt(n);i++){if(n%i==0){hs.add(i);hs.add(n/i);}}return hs;}
    static HashSet<Long> pf(long n){HashSet<Long> ff=factors(n);HashSet<Long> ans=new HashSet<Long>();for(Long i:ff)if(isPrime(i))ans.add(i);return ans;}
    static HashSet<Integer> pf(int n){HashSet<Integer> ff=factors(n);HashSet<Integer> ans=new HashSet<Integer>();for(Integer i:ff)if(isPrime(i))ans.add(i);return ans;}
    static int[] inpint(int n){int arr[]=new int[n];for(int i=0;i<n;i++){arr[i]=f.ni();}return arr;}
    static long[] inplong(int n){long arr[] = new long[n];for(int i=0;i<n;i++){arr[i]=f.nl();}return arr;}
    static boolean ise(int x){return ((x&1)==0);}static boolean ise(long x){return ((x&1)==0);}
    static int gnv(char c){return Character.getNumericValue(c);}
    static int upperbound(ArrayList<Integer> a,int i){int lo=0,hi=a.size()-1,mid=0;int count=0;while(lo<=hi){mid=(lo+hi)/2;if(a.get(mid)<=i){count=mid+1;lo=mid+1;}else hi=mid-1;}return count;}
    static int log(long x){return x==1?0:(1+log(x/2));} static int log(int x){return x==1?0:(1+log(x/2));}
    static void sort(int[] a){ArrayList<Integer> l=new ArrayList<>();for(int i:a)l.add(i);Collections.sort(l);for(int i=0;i<a.length;++i)a[i]=l.get(i);}
    static void sort(long[] a){ArrayList<Long> l=new ArrayList<>();for(long i:a)l.add(i);Collections.sort(l);for(int i=0;i<a.length;++i)a[i]=l.get(i);}
    static void sort(ArrayList<Integer> a){Collections.sort(a);}
}


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

public class CF1095D {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		if (n == 3) {
			System.out.println("1 2 3");
			return;
		}
		int[] aa = new int[n];
		int[] bb = new int[n];
		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			aa[i] = Integer.parseInt(st.nextToken()) - 1;
			bb[i] = Integer.parseInt(st.nextToken()) - 1;
		}
		StringBuilder sb = new StringBuilder();
		for (int h = 0, i = 0; h < n; h++) {
			sb.append((i + 1) + " ");
			int a = aa[i], b = bb[i];
			if (aa[a] != b && bb[a] != b) {
				int tmp = aa[i]; aa[i] = bb[i]; bb[i] = tmp;
			}
			i = aa[i];
		}
		System.out.println(sb);
	}
}


//Code by Sounak, IIEST
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Arrays;
public class Test1{
    public static void main(String args[])throws IOException{
        FastReader sc = new FastReader();
        StringBuilder sb = new StringBuilder();
        int n=sc.nextInt();
        int a[]=new int[n];
        int b[]=new int[n];
        HashMap <Integer, Integer> ar=new HashMap();
        //HashMap <Integer, Integer> br=new HashMap();
        int i,p=0;
        for(i=0;i<n;i++)
        {
            int n1=sc.nextInt();
            int n2=sc.nextInt();
            if(i==0)
            p=n2;
            if(ar.containsKey(n2) || ar.containsValue(n1))
            ar.put(n1,n2);
            else
            ar.put(n2,n1);
        }
        for(i=0;i<n;i++)
        {
            int temp=ar.get(p);
            System.out.print(temp+" ");
            p=temp;
        }
        System.out.println();
    }
}

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;
    }
}


//Code by Sounak, IIEST
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.Arrays;
public class Test1{
    public static void main(String args[])throws IOException{
        FastReader sc = new FastReader();
        int n=sc.nextInt();
        HashMap <Integer, Integer> ar=new HashMap();
        //HashMap <Integer, Integer> br=new HashMap();
        int i,p=0;
        for(i=0;i<n;i++)
        {
            int n1=sc.nextInt();
            int n2=sc.nextInt();
            if(i==0)
            p=n2;
            if(ar.containsKey(n2) || ar.containsValue(n1))
            ar.put(n1,n2);
            else
            ar.put(n2,n1);
        }
        for(i=0;i<n;i++)
        {
            int temp=ar.get(p);
            System.out.print(temp+" ");
            p=temp;
        }
        System.out.println();
    }
}

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.util.*;

public class Solution {

    public static void main(String[] args) throws Exception {
        MyScanner scan = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

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

        if (n == 3) {
            out.println("1 2 3");
        } else {
            int[] output = new int[n];
            int curr = 0;
            int index = 0;
            output[0] = 1;
            while (index != output.length - 1) {
                int next1 = nexts[curr][0];
                int next2 = nexts[curr][1];
                if (nexts[next1 - 1][0] == next2 || nexts[next1 - 1][1] == next2) {
                    output[++index] = next1;
                    if (index == output.length) break;
                    output[++index] = next2;
                    curr = next2 - 1;
                } else {
                    output[++index] = next2;
                    if (index == output.length) break;
                    output[++index] = next1;
                    curr = next1 - 1;
                }
            }
            for (int i : output) {
                out.print(i + " ");
            }
        }

        out.close();
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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.util.*;

public class Solution {

    public static void main(String[] args) throws Exception {
        MyScanner scan = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

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

        if (n == 3) {
            out.println("1 2 3");
        } else {
            int[] output = new int[n];
            int curr = 0;
            int index = 0;
            output[0] = 1;
            while (index != output.length - 1) {
                int next1 = nexts[curr][0];
                int next2 = nexts[curr][1];
                if (nexts[next1 - 1][0] == next2 || nexts[next1 - 1][1] == next2) {
                    output[++index] = next1;
                    if (index == output.length - 1) break;
                    output[++index] = next2;
                    curr = next2 - 1;
                } else {
                    output[++index] = next2;
                    if (index == output.length - 1) break;
                    output[++index] = next1;
                    curr = next1 - 1;
                }
            }
            for (int i : output) {
                out.print(i + " ");
            }
        }

        out.close();
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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;
        }

    }
    //--------------------------------------------------------

}


// package prac;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n=in.nextInt();
		int[][] arr = new int[n][2];
		for(int i =0;i<n;i++){
			arr[i][0] = in.nextInt();
			arr[i][1] = in.nextInt();
		}
		int[] res = new int[n];
		int[] check =new int[n+1];
		int j = 1;
//		check[j] = 1;
		for(int i = 0;i<n;i++){
			int a = arr[j-1][0];
			int b = arr[j-1][1];
			int c = arr[a-1][0];
			int d = arr[a-1][1];
			if(check[j]!=1&&(b==c||b==d)){
				res[i] = a;
				j = a;
			}else{
				res[i] = b;
				j = b;
			}
			check[j] = 1;
		}
		for(int i = 0;i<n;i++){
			out.print(res[i]+" ");
		}
		out.println();
		out.close();
	}
	static class InputReader {
	    public BufferedReader reader;
	    public StringTokenizer tokenizer;

	    public InputReader(InputStream stream) {
	        reader = new BufferedReader(new InputStreamReader(stream), 32768);
	        tokenizer = null;
	    }

	    public String next() {
	        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

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


// package prac;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n=in.nextInt();
		int[][] arr = new int[n][2];
		for(int i =0;i<n;i++){
			arr[i][0] = in.nextInt();
			arr[i][1] = in.nextInt();
		}
		int[] res = new int[n];
		int j = 1;
		for(int i = 0;i<n;i++){
			int a = arr[j-1][0];
			int b = arr[j-1][1];
			int c = arr[a-1][0];
			int d = arr[a-1][1];
			if(b==c||b==d){
				res[i] = a;
				j = a;
			}else{
				res[i] = b;
				j = b;
			}
		}
		for(int i = 0;i<n;i++){
			out.print(res[i]+" ");
		}
		out.println();
		out.close();
	}
	static class InputReader {
	    public BufferedReader reader;
	    public StringTokenizer tokenizer;

	    public InputReader(InputStream stream) {
	        reader = new BufferedReader(new InputStreamReader(stream), 32768);
	        tokenizer = null;
	    }

	    public String next() {
	        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

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


// package prac;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		InputReader in = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n=in.nextInt();
		int[][] arr = new int[n][2];
		for(int i =0;i<n;i++){
			arr[i][0] = in.nextInt();
			arr[i][1] = in.nextInt();
		}
		int[] res = new int[n];
		int[] check =new int[n+1];
		int j = 1;
//		check[j] = 1;
		for(int i = 0;i<n;i++){
			int a = arr[j-1][0];
			int b = arr[j-1][1];
			int c = arr[a-1][0];
			int d = arr[a-1][1];
			if(check[a]!=1&&(b==c||b==d)){
				res[i] = a;
				j = a;
			}else{
				res[i] = b;
				j = b;
			}
			check[j] = 1;
		}
		for(int i = 0;i<n;i++){
			out.print(res[i]+" ");
		}
		out.println();
		out.close();
	}
	static class InputReader {
	    public BufferedReader reader;
	    public StringTokenizer tokenizer;

	    public InputReader(InputStream stream) {
	        reader = new BufferedReader(new InputStreamReader(stream), 32768);
	        tokenizer = null;
	    }

	    public String next() {
	        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

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


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

public class d{

    static int n;
    static ArrayList<ArrayList<Integer>> adj = new ArrayList<ArrayList<Integer>>();
    static boolean[] visited;

   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));

      n = sc.nextInt();
      int[][] arr = new int[n][2];
      for(int i=0; i<n; i++) {
          arr[i][0] = sc.nextInt()-1;
          arr[i][1] = sc.nextInt()-1;
      }
      int[] ans = new int[n];
      ans[0]=0;
      for(int i=0; i<n-1; i++) {
          int k = arr[ans[i]][0];
          int l = arr[ans[i]][1];
          if(arr[k][0]==l|| arr[k][1]==l) {
              ans[i+1]=k;
          } else {
              ans[i+1]=l;
          }
      }
      if(n<4) {
          for(int i=0; i<n; i++) {
              out.print((i+1)+" ");
          }
      } else {
          for(int i=0; i<n; i++) {
              out.print((ans[i]+1)+" ");
          }
      }

      // Start writing your solution here. -------------------------------------

      /*
      int n      = sc.nextInt();        // read input as integer
      long k     = sc.nextLong();       // read input as long
      double d   = sc.nextDouble();     // read input as double
      String str = sc.next();           // read input as String
      String s   = sc.nextLine();       // read whole line as String

      int result = 3*n;
      out.println(result);                    // print via PrintWriter
      */

      // Stop writing your solution here. -------------------------------------
      out.close();
   }

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;

   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

      public MyScanner() {
         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.util.*;

public class d{

    static int n;
    static ArrayList<ArrayList<Integer>> adj = new ArrayList<ArrayList<Integer>>();
    static boolean[] visited;

   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));

      n = sc.nextInt();
      int[][] arr = new int[n][2];
      for(int i=0; i<n; i++) {
          arr[i][0] = sc.nextInt()-1;
          arr[i][1] = sc.nextInt()-1;
      }
      int[] ans = new int[n];
      ans[0]=0;
      for(int i=0; i<n-1; i++) {
          int k = arr[ans[i]][0];
          int l = arr[ans[i]][1];
          if(arr[k][0]==l|| arr[k][1]==l) {
              ans[i+1]=k;
          } else {
              ans[i+1]=l;
          }
      }
      if(n<4) {
          for(int i=0; i<n; i++) {
              out.print(i+" ");
          }
      } else {
          for(int i=0; i<n; i++) {
              out.print((ans[i]+1)+" ");
          }
      }

      // Start writing your solution here. -------------------------------------

      /*
      int n      = sc.nextInt();        // read input as integer
      long k     = sc.nextLong();       // read input as long
      double d   = sc.nextDouble();     // read input as double
      String str = sc.next();           // read input as String
      String s   = sc.nextLine();       // read whole line as String

      int result = 3*n;
      out.println(result);                    // print via PrintWriter
      */

      // Stop writing your solution here. -------------------------------------
      out.close();
   }

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;

   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

      public MyScanner() {
         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.io.Reader;
import java.util.*;
public class D {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        int N = scanner.nextInt();
        int[][] kids = new int[N][2];
        ArrayList<Integer>[] sees = new ArrayList[N];
        for(int i = 0; i < N; i++) sees[i] = new ArrayList<>();
        for(int i = 0; i < N; i++) {
            int a = scanner.nextInt()-1;
            int b= scanner.nextInt()-1;
            kids[i][0] = a;
            kids[i][1] = b;
            sees[a].add(i);
            sees[b].add(i);
        }
        StringBuilder stringBuilder = new StringBuilder();
        int nPlaced = 0;
        int curKid = 0;
        int nextKid = -1;
        int furthestKid = -1;
        int p1 = sees[curKid].get(0);
        int p2 = sees[curKid].get(1);
        if (sees[p1].contains(p2)) {
            nextKid = p1;
            furthestKid = p2;
        }
        else {
            nextKid = p2;
            furthestKid = p1;
        }
        while(nPlaced < N) {
            stringBuilder.append((curKid+1) + " " );
            curKid = nextKid;
            int k1 = sees[curKid].get(0);
            int k2 = sees[curKid].get(1);
            nextKid = furthestKid;
            furthestKid = (k1==nextKid) ? k2 : k1;
            nPlaced++;
        }
        System.out.println(stringBuilder.toString());
    }
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        public FastScanner() {
            this(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 readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.*;
public class D {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        int N = scanner.nextInt();
        int[][] kids = new int[N][2];
        ArrayList<Integer>[] sees = new ArrayList[N];
        for(int i = 0; i < N; i++) sees[i] = new ArrayList<>();
        for(int i = 0; i < N; i++) {
            int a = scanner.nextInt()-1;
            int b= scanner.nextInt()-1;
            kids[i][0] = a;
            kids[i][1] = b;
            sees[a].add(i);
            sees[b].add(i);
        }
        StringBuilder stringBuilder = new StringBuilder();
        int nPlaced = 0;
        int curKid = 0;
        int nextKid = -1;
        int furthestKid = -1;
        int p1 = sees[curKid].get(0);
        int p2 = sees[curKid].get(1);
        if (sees[p1].contains(p2)) {
            nextKid = p1;
            furthestKid = p2;
        }
        else {
            nextKid = p2;
            furthestKid = p1;
        }
        ArrayDeque<Integer> stack = new ArrayDeque<>();
        while(nPlaced < N) {
            stack.push(curKid+1);
            curKid = nextKid;
            int k1 = sees[curKid].get(0);
            int k2 = sees[curKid].get(1);
            nextKid = furthestKid;
            furthestKid = (k1==nextKid) ? k2 : k1;
            nPlaced++;
        }
        while(!stack.isEmpty()) {
            stringBuilder.append(stack.pop() + " ");
        }
        System.out.println(stringBuilder.toString());
    }
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        public FastScanner() {
            this(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 readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


import java.util.*;

public class CircularDance {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer, Queue<Integer>> tree = new HashMap<Integer, Queue<Integer>>();
        for (int i = 0; i < n; i++){
            int f = sc.nextInt();
            int s = sc.nextInt();
            if (!tree.containsKey(f)){
                tree.put(f,new LinkedList<Integer>());
            }
            if (!tree.containsKey(s)){
                tree.put(s,new LinkedList<Integer>());
            }
            tree.get(f).add(s);
            tree.get(s).add(f);
        }
        int last = -1;
        int focus = 1;
        ArrayList<Integer> order = new ArrayList<Integer>();
        while (true){
            if (last != -1 && focus == 1){
                break;
            }
            int dest = tree.get(focus).remove();
            if (dest == last){
                dest = tree.get(focus).remove();
            }
            order.add(dest);
            last = focus;
            focus = dest;
        }
        for (int i : order){
            System.out.print(i+" ");
        }
    }
}


import java.util.*;

public class CircularDance {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer, HashSet<Integer>> tree = new HashMap<Integer, HashSet<Integer>>();
        for (int i = 1; i <= n; i++){
            int f = sc.nextInt();
            int s = sc.nextInt();
            if (!tree.containsKey(i)){
                tree.put(i,new HashSet<Integer>());
            }
            tree.get(i).add(s);
            tree.get(i).add(f);
        }
        HashMap<Integer, Integer> treepath = new HashMap<Integer, Integer>();
        for (int i = 1; i <= n; i++){
            Iterator<Integer> it = tree.get(i).iterator();
            int f = 0;
            int s = 0;
            while(it.hasNext()){
                f = it.next();
                s = it.next();
            }
            if (!tree.get(f).contains(s) && tree.get(s).contains(f)){
                if (!treepath.containsKey(i)){
                    treepath.put(i,s);
                }
                if (!treepath.containsKey(s)){
                    treepath.put(s,f);
                }
            }
            if (!tree.get(s).contains(f) && tree.get(f).contains(s)){
                if (!treepath.containsKey(i)){
                    treepath.put(i,f);
                }
                if (!treepath.containsKey(s)){
                    treepath.put(f,s);
                }
            }
        }
        if (n == 3){
            treepath.put(1,2);
            treepath.put(2,3);
            treepath.put(3,1);
        }

        int last = -1;
        int focus = 1;
        ArrayList<Integer> order = new ArrayList<Integer>();
        while (true){
            if (last != -1 && focus == 1){
                break;
            }
            int dest = treepath.get(focus);
            order.add(dest);
            last = focus;
            focus = dest;
        }
        for (int i : order){
            System.out.print(i+" ");
        }
    }
}


import java.util.*;
import java.io.*;
public class Main {
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;
        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
    static class p{
        int x,y;
        public p(int x,int y){
            this.x=x;this.y=y;
        }
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();p[] arr = new p[n+1];for(int i=1;i<=n;i++)arr[i]=new p(sc.nextInt(),sc.nextInt());
        p temp = arr[1];int cnt=1;p next = arr[temp.x];String sb = "1 ";
        while(true){
            if(cnt==n){System.out.print(sb);return;}
            int temper,appended;
            if(next==arr[temp.x]){temper = temp.y;appended = temp.x;}
            else {temper = temp.x;appended = temp.y;}
            if(next.x==temper){sb+=appended+" ";temp = next;next = arr[next.x];cnt++;}
            else if(next.y==temper){sb+=appended+" ";temp = next;next=arr[next.y];cnt++;}
            else break;
        }
        temp = arr[1];cnt=1;next = arr[temp.y];sb = "1 ";
        while(true){
            if(cnt==n){System.out.print(sb);return;}
            int temper,appended;
            if(next==arr[temp.x]){temper = temp.y;appended = temp.x;}
            else {temper = temp.x;appended = temp.y;}
            if(next.x==temper){sb+=appended+" ";temp = next;next = arr[next.x];cnt++;}
            else if(next.y==temper){sb+=appended+" ";temp = next;next=arr[next.y];cnt++;}
            else break;
        }
    }
}


import java.util.*;
import java.io.*;
public class Main {
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;
        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
    static class p{
        int x,y;
        public p(int x,int y){
            this.x=x;this.y=y;
        }
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();p[] arr = new p[n+1];for(int i=1;i<=n;i++)arr[i]=new p(sc.nextInt(),sc.nextInt());
        p temp = arr[1];int cnt=1;p next = arr[temp.x];StringBuilder sb = new StringBuilder("1 ");
        while(true){
            if(cnt==n){System.out.print(sb);return;}
            int temper,appended;
            if(next==arr[temp.x]){temper = temp.y;appended = temp.x;}
            else {temper = temp.x;appended = temp.y;}
            if(next.x==temper){sb.append(appended).append(" ");temp = next;next = arr[next.x];cnt++;}
            else if(next.y==temper){sb.append(appended).append(" ");temp = next;next=arr[next.y];cnt++;}
            else break;
        }
        temp = arr[1];cnt=1;next = arr[temp.y];sb = new StringBuilder("1 ");
        while(true){
            if(cnt==n){System.out.print(sb);return;}
            int temper,appended;
            if(next==arr[temp.x]){temper = temp.y;appended = temp.x;}
            else {temper = temp.x;appended = temp.y;}
            if(next.x==temper){sb.append(appended).append(" ");temp = next;next = arr[next.x];cnt++;}
            else if(next.y==temper){sb.append(appended).append(" ");temp = next;next=arr[next.y];cnt++;}
            else break;
        }
    }
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int arr[][]=new int[n][2];
		for(int i=0;i<n;i++){
		    arr[i][0]=sc.nextInt()-1;
		    arr[i][1]=sc.nextInt()-1;
		}
		boolean visited[]=new boolean[n];
		//boolean check=true;
		int pos=0;
		ArrayList<Integer> queue = new ArrayList<Integer>(n);
		queue.add(0);
		queue.add(arr[0][0]);
		queue.add(arr[0][1]);
		visited[0]=true;
		visited[arr[0][1]]=true;
		visited[arr[0][0]]=true;
		pos=1;
        while(pos<n){
            int kk=queue.get(pos);
            int x=arr[kk][0];
            int y=arr[kk][1];
            if((visited[x]&&visited[y])||(!visited[x]&&!visited[y]))
                break;
            if(visited[x]){
                queue.add(y);
                visited[y]=true;
            }
            else{
                queue.add(x);
                visited[x]=true;
            }
            pos++;
           // System.out.println(queue);
        }
        int siz=queue.size();

        if(siz==n){
            for(int i=0;i<n;i++)
                System.out.print((queue.get(i)+1)+" ");
            System.out.println();
            return ;
        }
       // System.out.println("--------NEW PHASE------");
        for(int i=0;i<n;i++)
            visited[i]=false;
        queue.clear();
        queue.add(0);
		queue.add(arr[0][1]);
		queue.add(arr[0][0]);
		visited[0]=true;
		visited[arr[0][1]]=true;
		visited[arr[0][0]]=true;
		pos=1;
        while(pos<n){
            int kk=queue.get(pos);
            int x=arr[kk][0];
            int y=arr[kk][1];
             if((visited[x]&&visited[y])||(!visited[x]&&!visited[y]))
                break;
            if(visited[x]){
                queue.add(y);
                visited[y]=true;
            }
            else{
                queue.add(x);
                visited[x]=true;
            }
            pos++;
            //System.out.println(queue);
        }
	    for(int i=0;i<n;i++)
                System.out.print((queue.get(i)+1)+" ");
            System.out.println();

	}
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int arr[][]=new int[n][2];
		for(int i=0;i<n;i++){
		    arr[i][0]=sc.nextInt()-1;
		    arr[i][1]=sc.nextInt()-1;
		}
		boolean visited[]=new boolean[n];
		boolean check=true;
		int val=(int)(n*Math.random());

		ArrayList<Integer> queue = new ArrayList<Integer>(n);
		queue.add(val);
		queue.add(arr[val][0]);
		queue.add(arr[val][1]);
		visited[val]=true;
		visited[arr[val][1]]=true;
		visited[arr[val][0]]=true;
		int pos=1;
        while(pos<n){
            int kk=queue.get(pos);
            int x=arr[kk][0];
            int y=arr[kk][1];
            if((visited[x]&&visited[y])||(!visited[x]&&!visited[y]))
                break;
            if(visited[x]){
                queue.add(y);
                visited[y]=true;
            }
            else{
                queue.add(x);
                visited[x]=true;
            }
            pos++;
           // System.out.println(queue);
        }
        int siz=queue.size();

        if(siz>=n){
            for(int i=0;i<n;i++)
                System.out.print((queue.get(i)+1)+" ");
            System.out.println();
            return ;
        }
       // System.out.println("--------NEW PHASE------");
        for(int i=0;i<n;i++)
            visited[i]=false;
        queue.clear();
        queue.add(val);
		queue.add(arr[val][1]);
		queue.add(arr[val][0]);
		visited[val]=true;
		visited[arr[val][1]]=true;
		visited[arr[val][0]]=true;
		pos=1;
        while(pos<n){
            int kk=queue.get(pos);
            int x=arr[kk][0];
            int y=arr[kk][1];
             if((visited[x]&&visited[y])||(!visited[x]&&!visited[y]))
                break;
            if(visited[x]){
                queue.add(y);
                visited[y]=true;
            }
            else{
                queue.add(x);
                visited[x]=true;
            }
            pos++;
           // System.out.println(queue);
        }
	    for(int i=0;i<n;i++)
                System.out.print((queue.get(i)+1)+" ");
            System.out.println();

	}
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int arr[][]=new int[n][2];
		for(int i=0;i<n;i++){
		    arr[i][0]=sc.nextInt()-1;
		    arr[i][1]=sc.nextInt()-1;
		}
		boolean visited[]=new boolean[n];
		boolean check=true;
		int pos=0;
		ArrayList<Integer> queue = new ArrayList<Integer>(n);
		queue.add(0);
		queue.add(arr[0][0]);
		queue.add(arr[0][1]);
		visited[0]=true;
		visited[arr[0][1]]=true;
		visited[arr[0][0]]=true;
		pos=1;
        while(pos<n){
            int kk=queue.get(pos);
            int x=arr[kk][0];
            int y=arr[kk][1];
            if((visited[x]&&visited[y])||(!visited[x]&&!visited[y]))
                break;
            if(visited[x]){
                queue.add(y);
                visited[y]=true;
            }
            else{
                queue.add(x);
                visited[x]=true;
            }
            pos++;
           // System.out.println(queue);
        }
        int siz=queue.size();

        if(siz>=n){
            for(int i=0;i<n;i++)
                System.out.print((queue.get(i)+1)+" ");
            System.out.println();
            return ;
        }
       // System.out.println("--------NEW PHASE------");
        for(int i=0;i<n;i++)
            visited[i]=false;
        queue.clear();
        queue.add(0);
		queue.add(arr[0][1]);
		queue.add(arr[0][0]);
		visited[0]=true;
		visited[arr[0][1]]=true;
		visited[arr[0][0]]=true;
		pos=1;
        while(pos<n){
            int kk=queue.get(pos);
            int x=arr[kk][0];
            int y=arr[kk][1];
             if((visited[x]&&visited[y])||(!visited[x]&&!visited[y]))
                break;
            if(visited[x]){
                queue.add(y);
                visited[y]=true;
            }
            else{
                queue.add(x);
                visited[x]=true;
            }
            pos++;
           // System.out.println(queue);
        }
	    for(int i=0;i<n;i++)
                System.out.print((queue.get(i)+1)+" ");
            System.out.println();

	}
}


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

public class CircularDance {

    public static void main(String args[]) throws IOException {
        FastReader in = new FastReader();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        Task.solve(in, out);
        out.close();
    }

    static class Task {

        public static void solve(FastReader in, PrintWriter out) {
            int n= in.nextInt();
            int[][] a = new int[n+1][2];
            LinkedList<Integer> q = new LinkedList<>();
            q.add(1);
            for(int i=1;i<=n;i++){
                a[i][0] = in.nextInt();
                a[i][1] = in.nextInt();
            }
            if(n==3){
                System.out.println("1 2 3");
                return;
            }
            int prev = 1,curr,f;
            if(a[a[1][0]][0]==a[1][1] || a[a[1][0]][1]==a[1][1]){
                curr = a[1][0];
                f = a[1][1];
            }else{
                curr = a[1][1];
                f = a[1][0];
            }
            for(int i=0;i<n-1;i++){
                int x = a[curr][0]+a[curr][1]+curr-a[prev][0]-a[prev][1];
                q.add(curr);
                prev = curr;
                curr = f;
                f = x;
            }
            for(int i=0;i<n;i++){
                System.out.print(q.poll()+" ");
            }
        }
    }

    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.util.*;
import java.lang.*;
import java.io.*;

public class CircularDance {

    public static void main(String args[]) throws IOException {
        FastReader in = new FastReader();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        Task.solve(in, out);
        out.close();
    }

    static class Task {

        public static void solve(FastReader in, PrintWriter out) {
            int n= in.nextInt();
            int[][] a = new int[n+1][2];
            LinkedList<Integer> q = new LinkedList<>();
            q.add(1);
            for(int i=1;i<=n;i++){
                a[i][0] = in.nextInt();
                a[i][1] = in.nextInt();
            }
            if(n==3){
                System.out.println("1 2 3");
                return;
            }
            int prev = 1,curr,f;
            if(a[a[1][0]][0]==a[1][1] || a[a[1][0]][1]==a[1][1]){
                curr = a[1][0];
                f = a[1][0];
            }else{
                curr = a[1][1];
                f = a[1][0];
            }
            for(int i=0;i<n-1;i++){
                int x = a[curr][0]+a[curr][1]+curr-a[prev][0]-a[prev][1];
                q.add(curr);
                prev = curr;
                curr = f;
                f = x;
            }
            for(int i=0;i<n;i++){
                System.out.print(q.poll()+" ");
            }
        }
    }

    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.util.ArrayList;
import java.util.Scanner;

public class NEW {

		public static int ar[][];
		public static boolean good(int a,int b)
		{
			for(int i=0;i<2;i++)
			{
				if(ar[a][i]==b)
				{
					return true;
				}
			}
			return false;
		}
		public static int get_next(int a)
		{
			int u=ar[a][0];
			int v=ar[a][1];
			if(good(u,v))
			{
				return u;
			}else{
				return v;
			}
		}
		public static void main(String args[])
		{
			Scanner scan=new Scanner(System.in);
			int n=scan.nextInt();

			ar=new int[n+1][2];
			for(int i=1;i<=n;i++){
				int nex=scan.nextInt();
				int nexnex=scan.nextInt();
				ar[i][0]=nex;
				ar[i][1]=nexnex;
			}
			if(n==3)
			{
			    System.out.println(1+" "+2+" "3);
			}else{
			ArrayList<Integer> stack=new ArrayList<Integer>();
			stack.add(1);
			while(stack.size()<n){
				int val=stack.get(stack.size()-1);
				int next=get_next(val);
				stack.add(next);

			}
			for(int x:stack)
			{
				System.out.print(x+" ");
			}
			}
		}
}


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

public class NEW {

		public static int ar[][];
		public static boolean good(int a,int b)
		{
			for(int i=0;i<2;i++)
			{
				if(ar[a][i]==b)
				{
					return true;
				}
			}
			return false;
		}
		public static int get_next(int a)
		{
			int u=ar[a][0];
			int v=ar[a][1];
			if(good(u,v))
			{
				return u;
			}else{
				return v;
			}
		}
		public static void main(String args[])
		{
			Scanner scan=new Scanner(System.in);
			int n=scan.nextInt();
			ar=new int[n+1][2];
			for(int i=1;i<=n;i++){
				int nex=scan.nextInt();
				int nexnex=scan.nextInt();
				ar[i][0]=nex;
				ar[i][1]=nexnex;
			}
			ArrayList<Integer> stack=new ArrayList<Integer>();
			stack.add(1);
			while(stack.size()<n){
				int val=stack.get(stack.size()-1);
				int next=get_next(val);
				stack.add(next);

			}
			for(int x:stack)
			{
				System.out.print(x+" ");
			}

		}
}


#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
//#define int long long
//#define int unsigned long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        string f=s;
        set<char>se;
        for(int i=0;i<s.length();i++)
        {
            se.insert(s[i]);
        }
            sort(f.begin(),f.end());
            int rrr=1;
            for(int i=0;i<f.length()-1;i++)
            {
                int y=(f[i+1]-f[i]);
                if(y==1)
                {

                }
                else
                {
                    rrr=0;
                    break;
                }
            }

        if(s.length()==1)
        {
            cout<<"Yes"<<endl;
        }
        else if(se.size()==s.length())
        {
            int flag=0;
            for(int i=0;i<s.length();i++)
            {
                    int x=abs(s[i]-s[i+1]);
                    if(x==1)
                    {
                        flag=1;
                        break;
                    }
            }
            if(flag==1 && rrr==1)
            cout<<"Yes"<<endl;
            else
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
//#define int long long
//#define int unsigned long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        string f=s;
        set<char>se;
        for(int i=0;i<s.length();i++)
        {
            se.insert(s[i]);
        }
            sort(f.begin(),f.end());
            int rrr=1;
            for(int i=0;i<f.length()-1;i++)
            {
                int y=(f[i+1]-f[i]);
                if(y==1)
                {

                }
                else
                {
                    rrr=0;
                    break;
                }
            }

        if(s.length()==1)
        {
            if(s[0]=='a' || s[0]=='z' || s[0]=='A' || s[0]=='Z')
            cout<<"NO"<<endl;
            else
            cout<<"YES"<<endl;
        }
        else if(se.size()==s.length())
        {
            int flag=0;
            for(int i=0;i<s.length();i++)
            {
                    int x=abs(s[i]-s[i+1]);
                    if(x==1)
                    {
                        flag=1;
                        break;
                    }
            }
            if(flag==1 && rrr==1)
            cout<<"YES"<<endl;
            else
            cout<<"NO"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
//#define int long long
//#define int unsigned long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        string f=s;
        set<char>se;
        for(int i=0;i<s.length();i++)
        {
            se.insert(s[i]);
        }
            sort(f.begin(),f.end());
            int rrr=1;
            for(int i=0;i<f.length()-1;i++)
            {
                int y=(f[i+1]-f[i]);
                if(y==1)
                {

                }
                else
                {
                    rrr=0;
                    break;
                }
            }

        if(s.length()==1)
        {
            cout<<"YES"<<endl;
        }
        else if(se.size()==s.length())
        {
            int flag=0;
            for(int i=0;i<s.length();i++)
            {
                    int x=abs(s[i]-s[i+1]);
                    if(x==1)
                    {
                        flag=1;
                        break;
                    }
            }
            if(flag==1 && rrr==1)
            cout<<"YES"<<endl;
            else
            cout<<"NO"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
//#define int long long
//#define int unsigned long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        string f=s;
        set<char>se;
        for(int i=0;i<s.length();i++)
        {
            se.insert(s[i]);
        }
            sort(f.begin(),f.end());
            int rrr=1;
            for(int i=0;i<f.length();i++)
            {
                int y=(f[i+1]-f[i]);
                if(y==1)
                {

                }
                else
                {
                    rrr=0;
                    break;
                }
            }

        if(s.length()==1)
        {
            cout<<"Yes"<<endl;
        }
        else if(se.size()==s.length())
        {
            int flag=0;
            for(int i=0;i<s.length();i++)
            {
                    int x=abs(s[i]-s[i+1]);
                    if(x==1)
                    {
                        flag=1;
                        break;
                    }
            }
            if(flag==1 && rrr==1)
            cout<<"Yes"<<endl;
            else
            cout<<"No"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
//#define int long long
//#define int unsigned long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        string f=s;
        set<char>se;
        for(int i=0;i<s.length();i++)
        {
            se.insert(s[i]);
        }
            sort(f.begin(),f.end());
            int rrr=1;
            for(int i=0;i<f.length()-1;i++)
            {
                int y=int(f[i+1]-f[i]);
                if(y==1)
                {

                }
                else
                {
                    rrr=0;
                    break;
                }
            }

        if(s.length()==1)
        {
            cout<<"Yes"<<endl;
        }
        else if(se.size()<s.length())
        {
            cout<<"No"<<endl;
        }
        else if(se.size()==s.length())
        {
            int flag=0;
            for(int i=0;i<s.length();i++)
            {
                    int x=abs(s[i]-s[i+1]);
                    if(x==1)
                    {
                        flag=1;
                        break;
                    }
            }
            if(flag==1 && rrr==1)
            cout<<"Yes"<<endl;
            else
            cout<<"No"<<endl;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
//#define int long long
//#define int unsigned long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    while(n--)
    {
        string s;
        cin>>s;
        string f=s;
        set<char>se;
        for(int i=0;i<s.length();i++)
        {
            se.insert(s[i]);
        }
            sort(f.begin(),f.end());
            int rrr=1;
            for(int i=0;i<f.length()-1;i++)
            {
                int y=int(f[i+1]-f[i]);
                if(y==1)
                {

                }
                else
                {
                    rrr=0;
                    break;
                }
            }

        if(s.length()==1)
        {
            cout<<"Yes"<<endl;
        }
        else if(se.size()<s.length())
        {
            cout<<"No"<<endl;
        }
        else if(se.size()==s.length())
        {
            if(rrr==1)
            cout<<"Yes"<<endl;
            else
            cout<<"No"<<endl;
        }
    }

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	int n,f=1;
	cin>>n;
	string s;
	for(int i=0;i<n;i++)
	{
	    cin>>s;
	    int p=s.size();
	    if(p==1)
	    cout<<"YES\n";
	    else
	    {
	    sort(s.begin(),s.end());

	    for( int j=0;j<p-1;i++)

	    if(s[j+1]==s[j]+1)
	    f=0;

	    if(f==0)
	    cout<<"YES\n";
	    else
	    cout<<"NO\n";
	    }
	}
return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n,f=0;
	cin>>n;
	string s;
	for(int i=0;i<n;i++)
	{
	    cin>>s;

	    sort(s.begin(),s.end());

	    for( int j=0;j<s.size()-1;i++)
	  {
	    if((s[j+1]-s[j])!=1)
	    {
	    f=1;
	    break;
	    }

	  }
	    if(f==0)
	    cout<<"YES\n";
	    else
	    cout<<"NO\n";

	}
return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n,f=0;
	cin>>n;
	string s;
	for(int i=0;i<n;i++)
	{
	    cin>>s;

	    sort(s.begin(),s.end());

	    for( int j=0;j<s.size()-1;i++)
	  {
	    if(s[j+1]!=s[j]+1)
	    {
	    f=1;
	    break;
	    }

	  }
	    if(f==0)
	    cout<<"YES\n";
	    else
	    cout<<"NO\n";

	}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n;

    for(int i=0;i<n;i++)
    {   int flag=1;
        cin>>s;
        sort(s.begin(),s.end());
        for(int j=0;j<s.size()-1;j++)
        {
            if((s[j+1]-s[j])!=1)
            {

                flag=0;
                break;
            }

        }
        if(flag==1)
        cout<<"Yes\n";
        else
        cout<<"No\n";
    }

    return 0;
}


// so dumb that i didn't understand the problem in the first place
// that's why you shouldn't participate a coding contest (even div. 3)
// when you slept for only an hour lol

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    while (n--)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        bool flag = true;
        int len = s.length();
        for (int i = 1; i < len; i++)
        {
            if (s[i] - s[i - 1] != 1)
                flag = false;
        }
        if (flag)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}


// so dumb that i didn't understand the problem in the first place
// that's why you shouldn't participate a coding contest (even div. 3)
// when you slept for only an hour lol

#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    while (n--)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        bool flag = true;
        int len = s.length();
        for (int i = 1; i < len; i++)
        {
            if (s[i] - s[i - 1] != 1)
                flag = false;
        }
        if (flag)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string a[n];
    int b[26];
    bool flag = false;
    for (int i = 0; i < 26; i++)
        b[i] = 0;

    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < a[i].length() - 1; j++)
        {
            if (b[a[i][j] - 97] == 0 && b[a[i][j + 1] - 97] == 0)
            {
                if (a[i][j] == a[i][j + 1] + 1 || a[i][j] + 1 == a[i][j + 1])
                {
                    flag = true;
                    b[a[i][j] - 97] = 1;
                    b[a[i][j + 1] - 97] = 1;
                }
                else
                    flag = false;
            }
        }
        if (flag)
            cout << "Yes\n";
        else
            cout << "No\n";
        for (int i = 0; i < 26; i++)
            b[i] = 0;
    }
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string a[n];
    int b[26];
    bool flag = false;
    for (int i = 0; i < 26; i++)
        b[i] = 0;

    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < a[i].length() - 1; j++)
        {
            if (b[i] == 0 && b[i + 1] == 0)
            {
                if (a[i][j] == a[i][j + 1] + 1 || a[i][j] + 1 == a[i][j + 1])
                {
                    flag = true;
                    b[a[i][j] - 97] = 1;
                }
            }
            else
                flag = false;
        }
        if (flag)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <limits.h>

using namespace std;

int main(){

    int n;
    cin >> n;

    for(int i = 0; i < n; ++i){
        string s;
        getline(cin, s);
        int sum = 0, min = INT_MAX, value;
        int len = s.length();
        for(string::iterator it = s.begin(); it != s.end(); ++it){
            value = (int)*it;
            sum += value;
            if (min > value){
                min = value;
            }
        }

        (min * len + (len*(len-1)) / 2) == sum ? cout << "Yes\n" : cout << "No\n";
    }
    return 0;
}


#include <iostream>
#include <limits.h>

using namespace std;

void check(string s){

    int sum = 0, min = INT_MAX, value, space;
    int len = s.length();
    string str = "";
    for(string::iterator it = s.begin(); it != s.end(); ++it){
        value = (int)*it;
        if (str.find(to_string(value)) != string::npos){
            cout << "No";
            return;
        }

        str += to_string(value) + ' ';

        sum += value;
        if (min > value){
            min = value;
        }
    }

    (min * len + (len*(len-1)) / 2) == sum ? cout << "Yes\n" : cout << "No\n";
}

int main(){

    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        check(s);
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <limits.h>

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<string> s;
    for(int i = 0; i < n; ++i){
        fflush(stdin);
        string a;
        cin >> a;
        s.push_back(a);
    }

    for(int i = 0; i < n; ++i){
        int sum = 0, min = INT_MAX, value;
        string a = s.at(i);
        int len = a.length();
        for(string::iterator it = a.begin(); it != a.end(); ++it){
            value = (int)*it;
            sum += value;
            if (min > value){
                min = value;
            }
        }

        (min * len + (len*(len-1)) / 2) == sum ? cout << "Yes\n" : cout << "No\n";
    }
    return 0;
}


#include <iostream>
#include <limits.h>

using namespace std;

void check(string s){

    int sum = 0, min = INT_MAX, value, space, check = 1;
    int len = s.length();
    string str = "";
    for(string::iterator it = s.begin(); it != s.end(); ++it){
        value = (int)*it;
        if (str.find(to_string(value)) != string::npos){
            check = 1;
        }

        str += to_string(value) + ' ';

        sum += value;
        if (min > value){
            min = value;
        }
    }
    if (check){
        cout << "No\n";
    }
    else{
        (min * len + (len*(len-1)) / 2) == sum ? cout << "Yes\n" : cout << "No\n";
    }

}

int main(){

    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        check(s);
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <limits.h>

using namespace std;

int main(){

    int n;
    cin >> n;

    for(int i = 0; i < n; ++i){
        string s;
        getline(cin, s);
        int sum = 0, min = INT_MAX, value;
        int len = s.length();
        for(string::iterator it = s.begin(); it != s.end(); ++it){
            value = (int)*it;
            sum += value;
            if (min > value){
                min = value;
            }
        }

        (min * len + (len*(len-1)) / 2) == sum ? cout << "Yes\n" : cout << "No\n";
    }
    FileIn.close();
    return 0;
}


#include <iostream>
#include <fstream>
#include <limits.h>

using namespace std;

int main(){

    int n;
    cin >> n;

    for(int i = 0; i < n; ++i){
        string s;
        fflush(stdin);
        getline(cin, s);
        int sum = 0, min = INT_MAX, value;
        int len = s.length();
        for(string::iterator it = s.begin(); it != s.end(); ++it){
            value = (int)*it;
            sum += value;
            if (min > value){
                min = value;
            }
        }

        (min * len + (len*(len-1)) / 2) == sum ? cout << "Yes\n" : cout << "No\n";
    }
    return 0;
}


#include <iostream>
#include <limits.h>

using namespace std;

void check(string s){

    int sum = 0, min = INT_MAX, value;
    int len = s.length();
    string str = "";
    for(string::iterator it = s.begin(); it != s.end(); ++it){
        value = (int)*it;
        if (str.find(to_string(value)) != string::npos){
            cout << "No\n";
            return;
        }

        str += to_string(value) + ' ';

        sum += value;
        if (min > value){
            min = value;
        }
    }
    (min * len + (len*(len-1)) / 2) == sum ? cout << "Yes\n" : cout << "No\n";

}

int main(){

    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        check(s);
    }
    return 0;
}


#include <iostream>
#include <limits.h>

using namespace std;

void check(string s){

    int sum = 0, min = INT_MAX, value;
    int len = s.length();
    for(string::iterator it = s.begin(); it != s.end(); ++it){
        value = (int)*it;
        sum += value;
        if (min > value){
            min = value;
        }
    }
    (min * len + (len*(len-1)) / 2) == sum ? cout << "Yes\n" : cout << "No\n";
}

int main(){

    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        check(s);
    }
    return 0;
}


#include <iostream>
#include <limits.h>

using namespace std;

void check(string s){

    int sum = 0, min = INT_MAX, value, space, check = 1;
    int len = s.length();
    string str = "";
    for(string::iterator it = s.begin(); it != s.end(); ++it){
        value = (int)*it;
        if (str.find(to_string(value)) != string::npos){
            check = 0;
        }

        str += to_string(value) + ' ';

        sum += value;
        if (min > value){
            min = value;
        }
    }
    if (check){
        (min * len + (len*(len-1)) / 2) == sum ? cout << "Yes\n" : cout << "No\n";
    }
    else{
        cout << "No\n";
    }

}

int main(){

    int n;
    cin >> n;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        check(s);
    }
    return 0;
}


//   ALLAH IS THE ALMIGHTY   //
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FOR(i,n)for(int i=0;i<(int)n;i++)
#define ROF(i,n)for(int i=(int)n-1;i>=0;i--)
typedef long long l;
const int N=5e6+5;
void  solve(){
  int n;
  cin>>n;
  while(n--){
    int sum(0);
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    FOR(i,s.size()-1){
    sum+=s[i+1]-s[i];
    }
    if(sum==s.size()-1)cout<<"YES"<<endl;
    else{
      if(s.size()==1)cout<<"YES\n";
      else cout<<"NO"<<endl;
    }
  }
  //sum+=s[s.size()-1]-s[s.size()-2];
  //cout<<sum<<endl;
  //sum=0;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  //int t;
  //cin>>t;
  //while(t--)//cout<<solve()<<endl;
      solve();
return 0;
}
//           SOLVED!            //


//   ALLAH IS THE ALMIGHTY   //
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FOR(i,n)for(int i=0;i<(int)n;i++)
#define ROF(i,n)for(int i=(int)n-1;i>=0;i--)
typedef long long l;
const int N=5e6+5;
void  solve(){
  string s;
  cin>>s;
  puts(s[0]=='a'||s[0]=='b'?"NO":"YES");
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  int t;
  cin>>t;
  while(t--)//cout<<solve()<<endl;
      solve();
return 0;
}
//           SOLVED!            //


//   ALLAH IS THE ALMIGHTY   //
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FOR(i,n)for(int i=0;i<(int)n;i++)
#define ROF(i,n)for(int i=(int)n-1;i>=0;i--)
typedef long long l;
const int N=5e6+5;
void  solve(){
  int n;
  cin>>n;
  while(n--){
    int sum(0);
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s.size()==1){
      cout<<"YES\n";
     // return;
    }else{
      FOR(i,s.size()-1){
      sum+=s[i+1]-s[i];
      }
      if(sum==s.size()-1)cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
      //return ;
    }
  }
  //sum+=s[s.size()-1]-s[s.size()-2];
  //cout<<sum<<endl;
  //sum=0;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  //int t;
  //cin>>t;
  //while(t--)//cout<<solve()<<endl;
      solve();
return 0;
}
//           SOLVED!            //


//   ALLAH IS THE ALMIGHTY   //
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FOR(i,n)for(int i=0;i<(int)n;i++)
#define ROF(i,n)for(int i=(int)n-1;i>=0;i--)
typedef long long l;
const int N=5e6+5;
int  solve(){
  int n,a,b,c,d,mx(0);
  cin>>n>>a>>b>>c>>d;
  mx=a+b+c+d;
  int ans(1);
  for(int i=2;i<=n;i++){
    cin>>a>>b>>c>>d;
    if(a+b+c+d>mx)ans++;
  }
  return ans;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  //int t;
  //cin>>t;
  //while(t--)
  cout<<solve()<<endl;
      //solve();
return 0;
}
//           SOLVED!            //


//   ALLAH IS THE ALMIGHTY   //
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FOR(i,n)for(int i=0;i<(int)n;i++)
#define ROF(i,n)for(int i=(int)n-1;i>=0;i--)
typedef long long l;
const int N=5e6+5;
void  solve(){
  int n;
  cin>>n;
  while(n--){
    int sum(0);
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    FOR(i,s.size()-1){
      if(s[i+1]-s[i]==1)
        sum+=s[i+1]-s[i];
    }
    if(sum==s.size()-1)cout<<"YES"<<endl;
    else{
      if(s.size()==1)cout<<"YES\n";
      else cout<<"NO"<<endl;
    }
  }
  //(set<char>(s.begin(), s.end()).size() == s.length()
              //  && *max_element(s.begin(), s.end()) == char(*min_element(s.begin(), s.end()) + (s.length() - 1)))
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  //int t;
  //cin>>t;
  //while(t--)//cout<<solve()<<endl;
      solve();
return 0;
}
//           SOLVED!            //


#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	string s;
	cin>>s;
	vector<int>ok;
	set<int>p;
	for(char x: s)
	{
		ok.push_back((int)x);
		p.insert(int(x));
	}
	sort(ok.begin(),ok.end());
	int x=p.size();
	int q=ok.size();
	if(x!=q){cout<<"No\n"; continue;}
	if(ok[x-1]-ok[0]+1==x)
	{
		cout<<"Yes"<<endl;
	}
	else{ cout<<"No"<<endl;
	}
}
		//	snmmnmkgkhhhg

}


#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	string s;
	cin>>s;
	vector<int>ok;
	set<int>p;
	for(char x: s)
	{
		ok.push_back((int)x);
		p.insert(int(x));
	}
	sort(ok.begin(),ok.end());
	int x=p.size();
	int q=ok.size();
	if(x!=q){cout<<"No\n";}
	if(ok[x-1]-ok[0]+1==x)
	{
		cout<<"Yes"<<endl;
	}
	else{ cout<<"No"<<endl;
	}
}
		//	snmmnmkgkhhhg

}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	string s;
	cin>>s;
	vector<int>ok;
	for(char x: s)
	{
		ok.push_back((int)x);
	}
	sort(ok.begin(),ok.end());
	int x=ok.size();
	if(ok[x-1]-ok[0]+1==x)
	{
		cout<<"Yes"<<endl;
	}
	else{ cout<<"No"<<endl;
	}
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	string s;
	cin>>s;
	vector<int>ok;
	set<int>p;
	for(char x: s)
	{
		ok.push_back((int)x);
		p.insert(int(x));
	}
	sort(ok.begin(),ok.end());
	int x=p.size();
	if(ok[x-1]-ok[0]+1==x)
	{
		cout<<"Yes"<<endl;
	}
	else{ cout<<"No"<<endl;
	}
}
		//	snmmnmkgkhhhg

}