#include <bits/stdc++.h>
using namespace std;
const long long p = 239017;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<vector<long long> > g(n + 1);
  for (long long i = 0; i < m; ++i) {
    long long iz, t;
    cin >> iz >> t;
    g[iz].push_back(t);
    g[t].push_back(iz);
  }
  set<long long> sit;
  vector<long long> res, used(n + 1);
  queue<long long> q;
  res.push_back(1);
  q.push(1);
  used[1] = 1;
  while (!q.empty()) {
    long long st = q.front();
    q.pop();
    for (auto el : g[st]) {
      if (!used[el]) sit.emplace(el);
    }
    if (sit.size() > 0) {
      long long sl = *sit.begin();
      sit.erase(sit.begin());
      used[sl] = 1;
      res.push_back(sl);
      q.push(sl);
    }
  }
  for (auto el : res) cout << el << " ";
  return 0;
}
