#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18;
const int len = (int)1e5;
vector<vector<int>> g;
bool used[len];
int main() {
  int n, m;
  cin >> n >> m;
  int v, u;
  g = vector<vector<int>>(n);
  for (int i = 0; i < m; i++) {
    cin >> v >> u;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<int> ans;
  priority_queue<int, vector<int>, greater<int>> q;
  q.push(0);
  while (!q.empty()) {
    int cur = q.top();
    q.pop();
    if (used[cur]) continue;
    ans.push_back(cur + 1);
    used[cur] = true;
    for (int i = 0; i < (int)g[cur].size(); i++) {
      if (!used[g[cur][i]]) {
        q.push(g[cur][i]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
