#include <bits/stdc++.h>
using namespace std;
set<long long int> check;
vector<long long int> ans;
vector<set<long long int>> gr(100005);
bool b[100005] = {false};
void DFS(long long int ind) {
  long long int i;
  b[ind] = true;
  ans.emplace_back(ind);
  for (auto x : gr[ind]) {
    if (b[x] == false) check.insert(x);
  }
  while (check.size()) {
    long long int val = *(check.begin());
    check.erase(check.begin());
    DFS(val);
  }
}
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  fastio();
  int T = 1;
  while (T--) {
    long long int n, m, i, t1, t2;
    cin >> n >> m;
    for (i = 0; i < m; i++) {
      cin >> t1 >> t2;
      gr[t1].insert(t2);
      gr[t2].insert(t1);
    }
    DFS(1);
    for (i = 0; i < ans.size(); i++) {
      cout << ans[i] << " ";
    }
  }
  return 0;
}
