#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 7;
vector<vector<int> > g;
vector<bool> used;
int main() {
  int n, m;
  cin >> n >> m;
  g.resize(n);
  used.resize(n, false);
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  set<int> q;
  q.insert(0);
  used[0] = true;
  while (!q.empty()) {
    int u = *q.begin();
    q.erase(q.begin());
    cout << u + 1 << ' ';
    for (auto v : g[u])
      if (!used[v]) {
        q.insert(v);
        used[v] = true;
      }
  }
  return 0;
}
