#include<bits/stdc++.h>
using namespace std;
const int N=210;
int mapp[N][N],m,n,k,ans,lb;
int w[N*4],a[N];
int read()
{
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
return x*f;
}
void dfs(int x)
{
for (int i=1;i<=n;i++)
if (mapp[x][i])
{
ans++;
mapp[x][i]--;
mapp[i][x]--;
dfs(i);
}
lb++;a[lb]=x;
}
int main()
{
freopen("carrier.in","r",stdin);
freopen("carrier.out","w",stdout);
n=read();m=read();
for (int i=1;i<=n;i++) w[i]=read();
for (int i=1;i<=m;i++)
{
int x=read(),y=read();
mapp[x][y]++;
mapp[y][x]++;
}
dfs(1);
printf("%d\n",ans);
for (int i=lb;i>0;i--)
printf("%d ",a[i]);
return 0;
}