#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v, u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  priority_queue<int, vector<int>, greater<int>> ac;
  vector<int> ans;
  vector<bool> used(n, false);
  ac.push(0);
  while (!ac.empty()) {
    int u = ac.top();
    ac.pop();
    if (used[u]) continue;
    ans.push_back(u);
    used[u] = true;
    for (auto &v : g[u]) {
      if (!used[v]) ac.push(v);
    }
  }
  for (auto &x : ans) cout << x + 1 << " ";
  cout << endl;
}
