#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (const auto &v : vec) {
    os << v << ",";
  }
  os << "]";
  return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
void solve() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> E(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  set<int> S;
  set<int> next;
  for (int i = 0; i < E[0].size(); i++) {
    next.insert(E[0][i]);
  }
  S.insert(0);
  vector<int> ans;
  ans.push_back(0);
  for (int k = 1; k < N; k++) {
    int v = -1;
    do {
      if (next.size() == 0) break;
      v = *next.begin();
      next.erase(next.begin());
    } while (S.find(v) != S.end());
    if (v == -1) break;
    ans.push_back(v);
    S.insert(v);
    for (int i = 0; i < E[v].size(); i++) {
      if (S.find(E[v][i]) == S.end()) {
        next.insert(E[v][i]);
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] + 1;
    if (i != N - 1) cout << " ";
  }
  cout << "\n";
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
}
