var
n,m,i,j,k,num:longint;
f:array[1..200,1..200]of longint;
w,ans:array[1..1000]of longint;
procedure dfs(x:longint);
var
i:longint;
begin
for i:=1 to n do
if (f[x,i]<>0) then
begin
dec(f[x,i]);dec(f[i,x]);dfs(i);
end;
inc(num);ans[num]:=x;
end;
begin
assign(input,'carrier.in');
reset(input);
assign(output,'carrier.out');
rewrite(output);
read(n,m);
for i:=1 to n do
read(w[i]);
for i:=1 to m do
begin
read(j,k);
inc(f[j,k]);
inc(f[k,j]);
end;
dfs(1);
writeln(m);
for i:=num downto 1 do write(ans[i],' ');
writeln;
end.