#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> g[N];
set<int> save;
bool done[N];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v), g[v].push_back(u);
  }
  done[1] = 1;
  save.insert(1);
  while (!save.empty()) {
    cout << *save.begin() << ' ';
    int u = *save.begin();
    save.erase(save.begin());
    for (auto v : g[u])
      if (!done[v]) {
        save.insert(v);
        done[v] = 1;
      }
  }
  return 0;
}
