#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000 + 10;
const int MOD = 1000 * 1000 * 1000 + 7;
int n, m;
priority_queue<int> q;
vector<int> ans, adj[MAXN];
bool mark[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v), adj[v].push_back(u);
  }
  q.push(0);
  while ((int)ans.size() != n) {
    int v = abs(q.top());
    ans.push_back(v);
    mark[v] = 1;
    q.pop();
    for (auto u : adj[v])
      if (!mark[u]) {
        mark[u] = 1;
        q.push(-u);
      }
  }
  for (auto u : ans) cout << u + 1 << " ";
  cout << "\n";
  return 0;
}
