#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 1e5 + 47;
long long n, m, used[MAX_N];
vector<long long> g[MAX_N];
set<long long> s;
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<long long> ans;
  s.insert(1);
  while (s.size()) {
    long long u = *s.begin();
    ans.push_back(u);
    used[u] = 1;
    s.erase(s.begin());
    for (auto v : g[u]) {
      if (!used[v]) {
        used[v] = 1;
        s.insert(v);
      }
    }
  }
  for (auto x : ans) {
    cout << x << ' ';
  }
  return 0;
}
