#include <bits/stdc++.h>
using namespace std;
const int dx[] = {1, -1, 1, -1};
const int dy[] = {1, -1, -1, 1};
const int maxn = 100005;
int n, m, vis[maxn];
priority_queue<int, vector<int>, greater<int> > pq;
vector<int> e[maxn], ans;
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  pq.push(1);
  vis[1] = 1;
  while (pq.size()) {
    int u = pq.top();
    pq.pop();
    ans.push_back(u);
    for (int i = 0; i < e[u].size(); i++) {
      if (vis[e[u][i]]) continue;
      vis[e[u][i]] = 1;
      pq.push(e[u][i]);
    }
  }
  cout << ans[0];
  for (int i = 1; i < ans.size(); i++) cout << ' ' << ans[i];
  return 0;
}
