{Решение задачи  ОЧЕРЕДЬ. }
{Автор задачи: Киндер М.И.}
program queue;
    var  a, b, X, Y : array[1..2000000] of integer;
               i, n : integer;

Procedure Print;
    var  t : integer;
begin
    t := Y[i];
    write(a[t]);
    while t > 0 do begin
          write(' ', b[t]);
          t := Y[b[t]];
    end;
end;

begin
     assign(input,   'queue.in'); reset(input);
     assign(output, 'queue.out'); rewrite(output);
     readln(n);

     for i := 1 to n-1 do read(a[i], b[i]);
     for i := 1 to n-1 do begin
         inc(X[a[i]]);  inc(X[b[i]]);
         Y[a[i]] := i;
         end;
     for i := 1 to n do
         if (X[i] = 1) and (Y[i] > 0) then Print;
     close(input);
     close(output);
end.