#include <stdio.h>



typedef unsigned short int bool;
typedef unsigned short int sint;
const sint dmax = 200, dd=201;
sint *A, *P, *S, *M; 
bool *Sz;
/*  A: ellista-matrix, P: szulo pointer, 
    S: sor, M: mutato vektor, Sz: szin */
sint i, j, ii, jj, k, l, n, N, m, u, v, w, eleje = 0, vege = 0; 
int x;

int cim(i,j)
{
/* Az A matrixot inkabb vektorban taroljuk, mert a C-ben igy szebb.
   Ekkor A[i][j] helyett A[cim(i,j)]-t irunk.
   1<=i<=n ; 0<=j<=dd-1 */
    return((i-1)*dd+j);
}

main(argc, argv)
int argc;
char *argv[];
{

/* n beolvasa es helyfoglalas a tomboknek */

    scanf("%u",&n);
    N = n+1;

    if ((A = (void *) calloc(n*dd, sizeof(sint))) == NULL) {
	printf("Allocation error\n");
	exit(2);
    }
    if ((S = (void *) calloc(N, sizeof(sint))) == NULL) {
	printf("Allocation error\n");
	exit(2);
    }
    if ((P = (void *) calloc(N, sizeof(sint))) == NULL) {
	printf("Allocation error\n");
	exit(2);
    }
    if ((M = (void *) calloc(N, sizeof(sint))) == NULL) {
	printf("Allocation error\n");
	exit(2);
    }
    if ((Sz = (void *) calloc(N, sizeof(bool))) == NULL) {
	printf("Allocation error\n");
	exit(2);
    }
 
/* Sor kezelo rutinok */

    void sorba(sint u)
	{
	    S[vege] = u;
	    vege++;
	}

    sint sorbol()
	{
	    eleje++;
	    return(S[eleje-1]);
	}

    bool sornemures()
	{
	    return (eleje < vege);
	}


/* Adatok beolvasasa */

    while ((x =scanf("%u %u", &i, &j)) != EOF) {
	if (M[i] < dmax && M[j] < dmax && x == 2) {
	    A[cim(i,M[i])] = j;
	    M[i]++;
	    A[cim(j,M[j])] = i;
	    M[j]++;
	}
    }

/* A lenyeg: a szelessegi kereses eljarasa */

    for (i=1; i<=n; i++) {
	if (P[i] == 0) {
	    P[i] = i;
	    sorba(i);
	    while (sornemures() > 0) {
		j = sorbol();
		for (l=0; l<dd; l++) {
		    jj = A[cim(j,l)];
		    if (jj == 0) {
			l = dd;
		    } else {
			if (P[jj] == 0) {
			    sorba(jj);
			    P[jj] = j;
			    Sz[jj] = 1-Sz[j];
			} else {
			    if (Sz[j] == Sz[jj]) {
/* j es jj szomszedosak, de azonos szinuek. 
   Mar csak a paratlan kort kell megtalalni es kiiratni. */
				sint *bal, *jobb;

				k = 0;
				if ((bal = (void *) calloc(N, sizeof(sint))) == NULL) {
				    printf("Allocation error\n");
				    exit(2);
				}
				if ((jobb = (void *) calloc(N, sizeof(sint))) == NULL) {
				    printf("Allocation error\n");
				    exit(2);
				}

				bal[k] = j;
				jobb[k] = jj;
				while (bal[k] != jobb[k]) {
				    k++;
				    bal[k] = P[bal[k-1]];
				    jobb[k] = P[jobb[k-1]];
				}
				for (i=0; i<k; i++) printf("%d\n",bal[i]);
				for (i=k; i>0; i--) printf("%d\n",jobb[i]);
				printf("%d\n",jobb[0]);
				exit(0);
			    }
			}
		    }
		}
	    }
	}
    }

/* Sikerult a ketszinezes, kiirjuk az eredmenyt */
    for (i=1; i<=n; i++) if (Sz[i] == 0) printf("%d\n",i);
    exit(0);

}

