#include <bits/stdc++.h>
using namespace std;
void find(vector<vector<int> > &G) {
  set<int> vis;
  set<int> kn;
  vis.insert(0);
  while (!vis.empty()) {
    int fi = *vis.begin();
    kn.insert(fi);
    vis.erase(vis.begin());
    cout << (fi + 1) << " ";
    for (int x : G[fi]) {
      if (kn.count(x)) continue;
      vis.insert(x);
    }
  }
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  while (cin >> n >> m) {
    vector<vector<int> > G(n);
    int fr, to;
    for (__typeof(0) i = (0); i < (m); i++) {
      cin >> fr >> to;
      fr--;
      to--;
      G[fr].push_back(to);
      G[to].push_back(fr);
    }
    find(G);
  }
  return 0;
}
