#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  vector<list<int>> map;
  int i, j, k;
  int u, v;
  priority_queue<int, deque<int>, greater<int>> pq;
  int cur;
  vector<bool> visit;
  scanf("%d%d", &n, &m);
  map.resize(n + 1), visit.resize(n + 1, false);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    map[u].push_back(v);
    map[v].push_back(u);
  }
  pq.push(1);
  while (!pq.empty()) {
    cur = pq.top();
    pq.pop();
    if (!visit[cur]) {
      for (list<int>::iterator iter = map[cur].begin(); iter != map[cur].end();
           iter++) {
        pq.push(*iter);
      }
      visit[cur] = true;
      printf("%d ", cur);
    }
  }
  printf("\n");
  return 0;
}
