program zht;
var
i,t,n,m,x,y,ans,tn:longint;
a:array[0..1000000] of longint;
map:array[0..200,0..200] of longint;
procedure dfs(x:longint);
var
i:longint;
begin
for i:=1 to n do
if map[x,i]>0 then begin
inc(ans);
dec(map[x,i]);
dec(map[i,x]);
dfs(i);
end;
inc(tn);
a[tn]:=x;
end;
begin
assign(input,'carrier.in');
assign(output,'carrier.out');
reset(input);
rewrite(output);
readln(n,m);
for i:=1 to n do
readln(t);
for i:=1 to m do
begin
readln(x,y);
inc(map[x,y]);
inc(map[y,x]);
end;
dfs(1);
writeln(ans);
for i:=tn downto 1 do
write(a[i],' ');
close(input);
close(output);
end.