#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
const int maxm = 10010; //链表边数
int n = 0, m = 0;
int h[maxn] = {}, tot = 0;
struct edge //边属性
{
int to, nxt; //指向和下一个
}e[maxm];
int v[maxn] = {}; //标记
void addedge(int x, int y)
{
++tot;
e[tot].to = y;
e[tot].nxt = h[x];
h[x] = tot;
}
void dfs(int x)
{
printf("%d ", x);
v[x] = true;
for(int i=h[x]; i; i=e[i].nxt)
{
int y = e[i].to;
if(!v[y])
{
dfs(y);
}
}
}
int main()
{
int x = 0, y = 0;
scanf("%d%d", &n, &m);
for(int i=1; i<=m; i++)
{
scanf("%d%d", &x, &y);
addedge(x, y);
addedge(y, x);
}
dfs(1);
return 0;
}