#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
struct Edge {
  int nxt, v;
} e[(N << 1) + 3];
int vis[N + 3];
int ans[N + 3];
int fe[N + 3];
priority_queue<int, vector<int>, greater<int> > que;
int n, m, en;
void addedge(int u, int v) {
  en++;
  e[en].v = v;
  e[en].nxt = fe[u];
  fe[u] = en;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    addedge(x, y);
    addedge(y, x);
  }
  ans[1] = 1;
  vis[1] = true;
  for (int i = fe[1]; i; i = e[i].nxt) {
    que.push(e[i].v);
  }
  int cnt = 1;
  while (!que.empty()) {
    int u = que.top();
    que.pop();
    if (vis[u]) {
      continue;
    }
    cnt++;
    vis[u] = true;
    ans[cnt] = u;
    for (int j = fe[u]; j; j = e[j].nxt) {
      if (vis[e[j].v]) continue;
      que.push(e[j].v);
    }
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
