#include <bits/stdc++.h>
using namespace std;
bool visited[100008];
vector<vector<long long>> adj;
priority_queue<long long, vector<long long>, greater<long long>> q;
void bfs(long long a) {
  visited[a] = 1;
  q.push(a);
  while (!q.empty()) {
    long long v = q.top();
    q.pop();
    cout << v << " ";
    for (auto i : adj[v])
      if (!visited[i]) {
        visited[i] = 1;
        q.push(i);
      }
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m, x, y;
  cin >> n >> m;
  adj.resize(n + 1);
  for (long long i = 1; i <= m; i++) {
    cin >> x >> y;
    adj[x].push_back(y), adj[y].push_back(x);
  }
  bfs(1);
  cout << endl;
  return 0;
}
