#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  clock_t launch = clock();
  long long t = 1;
  while (t--) {
    int n, m, u, v, cur;
    cin >> n >> m;
    bool vis[n + 1];
    memset(vis, false, sizeof vis);
    priority_queue<int, vector<int>, greater<int> > q;
    vector<int> g[n + 1], ans;
    for (long long i = 0; i < m; i++) {
      cin >> u >> v;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    q.push(1);
    vis[1] = true;
    while (!q.empty()) {
      cur = q.top();
      ans.push_back(cur);
      q.pop();
      for (long long i = 0; i < g[cur].size(); i++)
        if (!vis[g[cur][i]]) {
          q.push(g[cur][i]);
          vis[g[cur][i]] = true;
        }
    }
    for (auto i : ans) cout << i << " ";
    cout << endl;
  }
  clog << ((long double)(clock() - launch) / CLOCKS_PER_SEC) << "\n";
  return 0;
}
