#include <bits/stdc++.h>
using namespace std;
long long denom = 1000000007;
long long temp;
set<long long> possibleNext;
int main(int argc, const char* argv[]) {
  long long n, m;
  cin >> n >> m;
  vector<pair<vector<long long>, bool>> V;
  for (long long j = (0); j < (n); j++) {
    vector<long long> t;
    V.push_back(make_pair(t, false));
  }
  long long v1, v2;
  for (long long j = (0); j < (m); j++) {
    cin >> v1 >> v2;
    V[v1 - 1].first.push_back(v2 - 1);
    V[v2 - 1].first.push_back(v1 - 1);
  }
  V[0].second = true;
  cout << 1 << " ";
  for (long long j = (0); j < (V[0].first.size()); j++) {
    if (!V[V[0].first[j]].second) possibleNext.insert(V[0].first[j]);
  }
  for (long long i = (0); i < (n - 1); i++) {
    long long ind = *(possibleNext.begin());
    cout << (ind + 1) << " ";
    V[ind].second = true;
    possibleNext.erase(possibleNext.begin());
    for (long long j = (0); j < (V[ind].first.size()); j++) {
      if (!V[V[ind].first[j]].second) {
        possibleNext.insert(V[ind].first[j]);
      }
    }
  }
  return 0;
}
