#include <cstdio>
#include <string>
using namespace std;
int MAP[10][10];
int n,m;
int Bool[10];
int main()
{
int Queue[1000],tail=0,head=0;
int t1,t2;
scanf("%d %d",&n,&m);
for(int i=0;i<m;i++)
{
scanf("%d %d",&t1,&t2);
MAP[t1][t2] = 1;
MAP[t2][t1] = 1;
}
Queue[tail++]=1;
Bool[1] = 1;
while(tail!=head)
{
for(int i=0;i<10;i++)
{
if(MAP[Queue[head]][i] == 1 && Bool[i] != 1){
// printf("%d ",i);
Queue[tail++] = i;
Bool[i] = 1;
}
}
head++;
}
for(int i=0;i<tail;i++)
printf("%d ",Queue[i]);
return 0;
}
09-03