#include <bits/stdc++.h>
using namespace std;
vector<int> edge[100100];
priority_queue<int> note;
queue<int> res;
char vis[100100];
int n, m, a, b;
int shit = 100100;
void wander(int pos) {
  note.pop();
  pos = shit - pos;
  if (vis[pos]) return;
  res.push(pos);
  vis[pos] = 1;
  for (vector<int>::iterator it = edge[pos].begin(); it != edge[pos].end();
       it++) {
    note.push(shit - (*it));
  }
}
int main() {
  memset(vis, 0, sizeof(vis));
  scanf("%d%d", &n, &m);
  while (m--) {
    scanf("%d%d", &a, &b);
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  note.push(shit - 1);
  while (!note.empty()) {
    wander(note.top());
  }
  while (!res.empty()) {
    printf("%d", res.front());
    res.pop();
    if (!res.empty()) printf(" ");
  }
  printf("\n");
}
