#include <bits/stdc++.h>
using namespace std;
bool vis[100000 + 10];
priority_queue<int, vector<int>, greater<int> > Q;
vector<int> G[100000 + 10];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int u, v;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  Q.push(1);
  vis[1] = 1;
  for (int i = 1; i <= n; i++) {
    int t = Q.top();
    Q.pop();
    printf("%d ", t);
    for (int i = 0; i < G[t].size(); i++)
      if (!vis[G[t][i]]) vis[G[t][i]] = true, Q.push(G[t][i]);
  }
  return 0;
}
