#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const long long dx[8] = {-1, 0, 1, 0, -1, 1, 1, -1},
                dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long long kdx[8] = {-2, -1, 1, 2, 2, 1, -1, -2},
                kdy[8] = {1, 2, 2, 1, -1, -2, -2, -1};
const long long mxn = 1e5 + 10;
set<long long> adj[mxn];
long long vis[mxn];
vector<long long> ans;
priority_queue<long long, vector<long long>, greater<long long>> pq;
void solve() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= m; ++i) {
    long long a, b;
    cin >> a >> b;
    adj[a].insert(b);
    adj[b].insert(a);
  }
  vis[1] = 1;
  pq.push(1);
  while (!pq.empty()) {
    long long s = pq.top();
    pq.pop();
    ans.push_back(s);
    for (auto x : adj[s]) {
      if (!vis[x]) {
        pq.push(x);
        vis[x] = 1;
      }
    }
  }
  for (auto x : ans) {
    cout << x << ' ';
  }
}
int32_t main() {
  clock_t start = clock();
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  for (long long i = 1; i <= t; ++i) {
    solve();
  }
  double duration = (clock() - start) / (double)CLOCKS_PER_SEC;
  cerr << duration << 's' << "\n";
  return 0;
}
