#include <bits/stdc++.h>
using namespace std;
const int maxm = 1e5 + 5;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
int n, m;
int a[maxn];
struct edge {
  int u, v, w, next;
} e[maxm * 2];
int head[maxn];
bool vis[maxn];
int cnt;
priority_queue<int, vector<int>, greater<int> > q;
void addedge(int u, int v, int w) {
  e[cnt].u = u;
  e[cnt].v = v;
  e[cnt].w = w;
  e[cnt].next = head[u];
  head[u] = cnt++;
}
void add_edge(int u, int v, int w) {
  addedge(u, v, w);
  addedge(v, u, w);
}
void bfs() {
  vis[1] = 1;
  q.push(1);
  int temp = 1;
  while (!q.empty()) {
    int u = q.top();
    a[temp++] = u;
    q.pop();
    for (int i = head[u]; ~i; i = e[i].next) {
      int v = e[i].v;
      if (!vis[v]) {
        q.push(v);
        vis[v] = 1;
      }
    }
  }
}
int main() {
  cnt = 0;
  memset(vis, 0, sizeof(vis));
  memset(head, -1, sizeof(head));
  cin >> n >> m;
  int u, v;
  for (int i = 1; i <= m; i++) {
    cin >> u >> v;
    add_edge(u, v, 1);
  }
  bfs();
  for (int i = 1; i <= n; i++) {
    printf("%d%c", a[i], i == n ? '\n' : ' ');
  }
}
