2013-09-18 08:13

//By BLADEVIL
var
n, m :longint;
pre, other :array[..] of longint;
last :array[..] of longint;
flag :array[..] of boolean;
tot :longint;
ans :array[..] of longint;
i :longint;
l :longint; procedure connect(x,y:longint);
begin
inc(l);
pre[l]:=last[x];
last[x]:=l;
other[l]:=y;
end; procedure init;
var
i :longint;
x, y :longint;
begin
read(n,m);
for i:= to m do
begin
read(x,y);
connect(x,y);
connect(y,x);
end;
end; procedure dfs(x:longint);
var
p, q :longint;
begin
q:=last[x];
while q<> do
begin
p:=other[q];
if not flag[q] then
begin
flag[q]:=true;
dfs(p);
end;
q:=pre[q];
end;
inc(tot);
ans[tot]:=x;
end; begin
assign(input,'watch.in'); reset(input);
assign(output,'watch.out'); rewrite(output);
init;
dfs();
for i:=tot downto do writeln(ans[i]);
close(input); close(output);
end.
04-14 06:59