#include <bits/stdc++.h>
using namespace std;
vector<bool> vis;
vector<vector<int> > adj;
void bfs(int s) {
  priority_queue<int, vector<int>, greater<int> > q;
  q.push(s);
  while (!q.empty()) {
    int e = q.top();
    q.pop();
    if (vis[e] == 1) continue;
    cout << e << " ";
    vis[e] = 1;
    for (int i = 0; i < (adj[e].size()); i++) {
      if (!vis[adj[e][i]]) q.push(adj[e][i]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n, m;
  cin >> n >> m;
  adj.resize(n + 1);
  vis.resize(n + 1, 0);
  for (int i = 0; i < (m); i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  bfs(1);
  return 0;
}
