#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
struct node {
  int to;
  int next;
} E[maxn << 1];
int head[maxn], cnt;
void adding(int u, int v) {
  E[++cnt] = {v, head[u]};
  head[u] = cnt;
}
int vis[maxn];
int nn, mm;
void bfs() {
  priority_queue<int, vector<int>, greater<int> > q;
  q.push(1), vis[1] = 1;
  while (!q.empty()) {
    int u = q.top();
    q.pop();
    printf("%d ", u);
    for (int i = head[u]; i; i = E[i].next) {
      int x = E[i].to;
      if (!vis[x]) q.push(x);
      vis[x] = 1;
    }
  }
}
int main() {
  scanf("%d%d", &nn, &mm);
  while (mm--) {
    int u, v;
    scanf("%d%d", &u, &v);
    adding(u, v);
    adding(v, u);
  }
  bfs();
  return 0;
}
