#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  vector<bool> used(n, 0);
  set<int> q;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[--u].push_back(--v);
    g[v].push_back(u);
  }
  used[0] = 1;
  q.insert(0);
  while (!q.empty()) {
    int v = *q.begin();
    q.erase(q.begin());
    ans.push_back(v);
    for (int i = 0; i < g[v].size(); i++) {
      if (!used[g[v][i]]) {
        used[g[v][i]] = 1;
        q.insert(g[v][i]);
      }
    }
  }
  for (int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << " ";
  return 0;
}
