#include <bits/stdc++.h>
using namespace std;
vector<int> nodes[100000 + 1];
vector<int> ans;
vector<int> visited(100000 + 1);
void nfs() {
  set<int> ily;
  ily.insert(1);
  while ((int)ily.size() != 0) {
    auto firs = ily.begin();
    int first = *firs;
    visited[first] = 1;
    ily.erase(ily.begin());
    ans.push_back(first);
    int i = 0;
    while (i < (int)nodes[first].size()) {
      if (!visited[nodes[first][i]]) {
        ily.insert(nodes[first][i]);
      }
      i++;
    }
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int i = 0;
  while (i < m) {
    int a, b;
    cin >> a >> b;
    nodes[a].push_back(b);
    nodes[b].push_back(a);
    i++;
  }
  nfs();
  for (int disp = 0; disp < (int)ans.size(); disp++) {
    cout << ans[disp] << " ";
  }
  cout << '\n';
  ;
  return 0;
}
