#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  if (x < 0) return -x;
  return x;
}
template <class T>
T sqr(T a) {
  return a * a;
}
const double pi = acos(-1.0);
const double eps = 1e-8;
int vis[100010];
int p[100010];
int n, m, i, sz, u, v, t;
priority_queue<int> pq;
vector<int> vec, adj[100010];
int main() {
  while (2 == scanf("%d%d", &n, &m)) {
    int s = 0;
    for (i = 0; i < m; i++) {
      scanf("%d%d", &u, &v);
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    pq.push(1);
    p[1] = 1;
    while (!pq.empty()) {
      t = abs(pq.top());
      pq.pop();
      if (vis[t] == 0) {
        vec.push_back(t);
        s++;
        if (s == n) break;
      }
      if (vis[t] == 0) {
        vis[t] = 1;
        sz = adj[t].size();
        for (i = 0; i < sz; i++) {
          v = adj[t][i];
          if (vis[v] == 0 && p[v] == 0) {
            p[v] = 1;
            pq.push(-v);
          }
        }
      }
    }
    for (i = 0; i < n; i++) printf("%d ", vec[i]);
    printf("\n");
  }
  return 0;
}
