#include<bits/stdc++.h>
using namespace std;
int visit[1000];
int n, e;
vector<int>graph[1000];
void BFS(int source)
{
visit[source] = 1;
cout<<source<<" ";
queue<int>q;
q.push(source);
while(!q.empty())
{
int x = q.front();
q.pop();
for(int j = 0; j < graph[x].size(); j++)
{
int node = graph[x][j];
if(visit[node] == 0)
{
visit[node] = 1;
cout<<node<<" ";
q.push(node);
}
}
}
}
int main()
{
cin>>n>>e;
int u, v;
for(int i = 1; i <= e; i++)
{
cin>>u>>v;
graph[u].push_back(v);
graph[v].push_back(u);
}
BFS(1);
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IHZpc2l0WzEwMDBdOwppbnQgbiwgZTsKdmVjdG9yPGludD5ncmFwaFsxMDAwXTsKCnZvaWQgQkZTKGludCBzb3VyY2UpCnsKICAgIHZpc2l0W3NvdXJjZV0gPSAxOwogICAgY291dDw8c291cmNlPDwiICI7CiAgICBxdWV1ZTxpbnQ+cTsKICAgIHEucHVzaChzb3VyY2UpOwoKICAgIHdoaWxlKCFxLmVtcHR5KCkpCiAgICB7CiAgICAgICAgaW50IHggPSBxLmZyb250KCk7CiAgICAgICAgcS5wb3AoKTsKCiAgICAgICAgZm9yKGludCBqID0gMDsgaiA8IGdyYXBoW3hdLnNpemUoKTsgaisrKQogICAgICAgIHsKICAgICAgICAgICAgaW50IG5vZGUgPSBncmFwaFt4XVtqXTsKICAgICAgICAgICAgaWYodmlzaXRbbm9kZV0gPT0gMCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgdmlzaXRbbm9kZV0gPSAxOwogICAgICAgICAgICAgICAgY291dDw8bm9kZTw8IiAiOwogICAgICAgICAgICAgICAgcS5wdXNoKG5vZGUpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKCn0KCmludCBtYWluKCkKewogICAgY2luPj5uPj5lOwogICAgaW50IHUsIHY7CiAgICBmb3IoaW50IGkgPSAxOyBpIDw9IGU7IGkrKykKICAgIHsKICAgICAgICBjaW4+PnU+PnY7CiAgICAgICAgZ3JhcGhbdV0ucHVzaF9iYWNrKHYpOwogICAgICAgIGdyYXBoW3ZdLnB1c2hfYmFjayh1KTsKICAgIH0KICAgIEJGUygxKTsKfQo=
MTAgMTMgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMSA0ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMSAyICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgNCAzICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMiAzICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMyAxMCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMyA5ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMiA4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMiA3ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMiA1ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgNSA3ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgNyA4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgNSA4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgNSA2IA==
10 13 1 4 1 2 4 3 2 3 3 10 3 9 2 8 2 7 2 5 5 7 7 8 5 8 5 6