#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g(100001);
bool visit[100001];
int n, m, c;
int main() {
  priority_queue<int, vector<int>, greater<int> > pq;
  int u, v;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  pq.push(1);
  while (c != n) {
    int v = pq.top();
    pq.pop();
    if (visit[v]) continue;
    visit[v] = 1;
    ++c;
    cout << v;
    if (c != n) cout << " ";
    for (int i = 0; i < g[v].size(); i++)
      if (!visit[g[v][i]]) pq.push(g[v][i]);
  }
  return 0;
}
