#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N=5e5+10;
int n, m, ans[N], cnt, p, f;
struct node{int x, y;}tmp[N<<1];
bool cmp(node n1, node n2)
{
if (n1.x==n2.x) return n1.y>n2.y;
return n1.x<n2.x;
}
struct edge{int x, y, pre;}a[N<<1];int alen, last[N<<1];
void ins(int x, int y) {alen++;a[alen]={x, y, last[x]};last[x]=alen;}
vector<int> jhs;
bool v[N], to[N], huan[N];
int stack[N], top;
void dfs(int x, int fa)
{
ans[++cnt]=x;
for (int k=last[x];k;k=a[k].pre)
{
int y=a[k].y;
if (y==fa) continue;
dfs(y, x);
}
}
bool get_huan(int x, int fa)
{
for (int k=last[x];k;k=a[k].pre)
{
int y=a[k].y;
if (y==fa) continue;
if (v[y])
{
int temp;
do
{
temp=stack[top--];v[temp]=0;
huan[temp]=1;jhs.push_back(temp);
}while (temp!=y);
p=temp;to[temp]=1;
if (temp==1) return true;
do
{
temp=stack[top--];v[temp]=0;
to[temp]=1;
}while (temp!=1);
return true;
}
stack[++top]=y, v[y]=1;
if (get_huan(y, x)) return true;
stack[top--]=0, v[y]=0;
}
return false;
}
void init(int x, int fa)
{
if (x==p) {f=fa;return ;}
ans[++cnt]=x;v[x]=1;
for (int k=last[x];k;k=a[k].pre)
{
int y=a[k].y;
if (y==fa||v[y]) continue;
init(y, x);
}
}
void get_ans(int x, int fa, int lim, bool op)
{
if (x>lim&&huan[x]&&!op) {p=x;return ;}
else if (x==lim&&huan[x]&&op)
{
ans[++cnt]=x;
for (int k=last[x];k;k=a[k].pre)
{
int y=a[k].y;
if (y==fa||huan[y]) continue;
get_ans(y, x, lim, op);
}
return ;
}
ans[++cnt]=x;
for (int k=last[x];k;k=a[k].pre)
{
int y=a[k].y;
if (y==fa) continue;
get_ans(y, x, lim, op);
}
}
int main()
{
freopen("text.out", "w", stdout);
scanf("%d%d", &n, &m);
for (int i=1;i<=m;i++)
{
int x, y;scanf("%d%d", &x, &y);
tmp[i]={x, y};tmp[i+m]={y, x};
}
sort(tmp+1, tmp+2*m+1, cmp);
for (int i=1;i<=2*m;i++) ins(tmp[i].x, tmp[i].y);
if (m==n-1) dfs(1, 0);
else
{
v[1]=1;stack[++top]=1;get_huan(1, 0);
for (int k=last[1];k;k=a[k].pre)
{
int y=a[k].y;
if (to[y]||huan[y]) continue;
dfs(y, 1);
}
memset(stack, 0, sizeof stack);
memset(v, 0, sizeof v);top=0;
if (1!=p) init(1, 0);
int flag1=0, flag2=0;ans[++cnt]=p;
for (int k=last[p];k;k=a[k].pre)
{
int y=a[k].y;
if (huan[y])
if (flag1) flag2=y;
else flag1=y;
}
int t=p;
for (int k=last[t];k;k=a[k].pre)
{
int y=a[k].y;
if (y==f) continue;
if (y==flag1)
get_ans(y, t, flag2, 0);
else if (y==flag2)
get_ans(y, t, p, 1);
else dfs(y, t);
}
}
for (int i=1;i<=cnt;i++) printf("%d ", ans[i]);
return 0;
}
```