#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int n, m;
  cin >> n >> m;
  vector<vector<long long int>> g(n);
  for (long long int i = 0; i < m; i++) {
    long long int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  set<long long int> q;
  q.insert(0);
  vector<bool> used(n, false);
  vector<long long int> ans;
  while (!q.empty()) {
    auto v = (*q.begin());
    q.erase(q.begin());
    ans.push_back(v + 1);
    used[v] = true;
    for (auto u : g[v]) {
      if (!used[u]) q.insert(u);
    }
  }
  for (auto i : ans) cout << i << " ";
  return 0;
}
