#include <bits/stdc++.h>
const int MAXN = 100000 + 10;
std::vector<int> a[MAXN];
bool vis[MAXN];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    a[u].push_back(v);
    a[v].push_back(u);
  }
  std::priority_queue<int, std::vector<int>, std::greater<int> > pq;
  pq.push(1);
  while (!pq.empty()) {
    int tmp = pq.top();
    pq.pop();
    vis[tmp] = 1;
    printf("%d ", tmp);
    for (auto k : a[tmp]) {
      if (!vis[k]) {
        pq.push(k);
        vis[k] = true;
      }
    }
  }
  return 0;
}
