#include <bits/stdc++.h>
using namespace std;
bool vis[100005];
int n, m, tot, top, a[100005], c[100005], ans[100005], lnk[100005],
    net[100005 << 1], son[100005 << 1];
priority_queue<int, vector<int>, greater<int> > hep;
inline char nc() {
  static char buf[100000], *L = buf, *R = buf;
  return L == R && (R = (L = buf) + fread(buf, 1, 100000, stdin), L == R)
             ? EOF
             : *L++;
}
inline int read() {
  int ret = 0, f = 1;
  char ch = nc();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = nc();
  }
  while (ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = nc();
  return ret * f;
}
inline void add(int x, int y) {
  net[++tot] = lnk[x];
  son[tot] = y;
  lnk[x] = tot;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    add(x, y);
    add(y, x);
  }
  ans[top = 1] = 1;
  vis[1] = 1;
  for (int j = lnk[1]; j; j = net[j])
    if (!vis[son[j]]) hep.push(son[j]), vis[son[j]] = 1;
  while (top < n) {
    int x = hep.top();
    hep.pop();
    ans[++top] = x;
    for (int j = lnk[x]; j; j = net[j])
      if (!vis[son[j]]) hep.push(son[j]), vis[son[j]] = 1;
  }
  for (int i = 1; i < n; i++) printf("%d ", ans[i]);
  printf("%d\n", ans[n]);
  return 0;
}
