#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
inline void write(int x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
inline void writeputs(int x) { write(x), putchar('\n'); }
inline void writeputchar(int x) { write(x), putchar(' '); }
int n, m, tot, fir[100005], ans[100005];
struct edge {
  int nxt, to;
} e[200005];
bool vis[100005];
priority_queue<int, vector<int>, greater<int> > q;
void add(int u, int v) {
  e[++tot] = {fir[u], v};
  fir[u] = tot;
}
void dijkstra(int s) {
  q.push(s);
  int cnt = 0;
  while (!q.empty()) {
    int u = q.top();
    q.pop();
    vis[u] = 1;
    ans[++cnt] = u;
    for (int i = fir[u]; i; i = e[i].nxt) {
      int v = e[i].to;
      if (!vis[v]) {
        vis[v] = 1;
        q.push(v);
      }
    }
  }
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    add(u, v);
    add(v, u);
  }
  dijkstra(1);
  for (int i = 1; i <= n; i++) writeputchar(ans[i]);
  return 0;
}
