#include <bits/stdc++.h>
using namespace std;
vector<long long int> adj[200005];
vector<int> visited(200005, 0);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int x, y, n, m;
  cin >> n >> m;
  for (long long int i = 0; i <= m - 1; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  priority_queue<long long int, vector<long long int>, greater<long long int> >
      temp;
  cout << "1"
       << " ";
  visited[1] = 1;
  for (long long int i = 0; i <= adj[1].size() - 1; i++) {
    if (visited[adj[1][i]] == 0) {
      temp.push(adj[1][i]);
      visited[adj[1][i]] = 1;
    }
  }
  while (!temp.empty()) {
    long long int s = temp.top();
    cout << s << " ";
    temp.pop();
    for (long long int j = 0; j <= adj[s].size() - 1; j++) {
      if (visited[adj[s][j]] == 0) {
        temp.push(adj[s][j]);
        visited[adj[s][j]] = 1;
      }
    }
  }
  return 0;
}
