#include <bits/stdc++.h>
using namespace std;
int V[400005], Head[400005], Next[400005], TOT;
void add(int u, int v) {
  V[TOT] = v;
  Next[TOT] = Head[u];
  Head[u] = TOT++;
}
priority_queue<int, vector<int>, greater<int> > Q;
int tot;
int ans[400005 / 4];
int vis[400005 / 4];
void solve() {
  int u, v;
  tot = 0;
  memset(vis, 0, sizeof(vis));
  vis[1] = 1;
  Q.push(1);
  while (!Q.empty()) {
    u = Q.top();
    Q.pop();
    ans[tot++] = u;
    for (int i = Head[u]; i != -1; i = Next[i]) {
      v = V[i];
      if (vis[v]) continue;
      vis[v] = 1;
      Q.push(v);
    }
  }
}
int main() {
  int n, m;
  int u, v;
  while (~scanf("%d%d", &n, &m)) {
    TOT = 0;
    for (int i = 1; i <= n; i++) Head[i] = -1;
    for (int i = 0; i < m; i++) {
      scanf("%d%d", &u, &v);
      add(u, v);
      add(v, u);
    }
    while (!Q.empty()) Q.pop();
    solve();
    for (int i = 0; i < tot; i++) {
      printf("%d", ans[i]);
      if (i == tot - 1)
        printf("\n");
      else
        printf(" ");
    }
  }
  return 0;
}
