#include <bits/stdc++.h>
using namespace std;
set<int> s;
vector<int> v[500007], vans;
int cur, n, k, a, b, fix[500007], m;
int main() {
  cin >> n >> m;
  for (k = 1; k <= m; k++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  cur = 1;
  fix[cur] = 1;
  s.insert(1);
  while (vans.size() < n) {
    for (k = 0; k < v[cur].size(); k++) {
      if (fix[v[cur][k]] == 0) {
        s.insert(v[cur][k]);
        fix[v[cur][k]] = 1;
      }
    }
    vans.push_back(*(s.begin()));
    cur = *(s.begin());
    s.erase(*(s.begin()));
  }
  for (k = 0; k < n; k++) {
    cout << vans[k] << " ";
  }
}
