#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
priority_queue<long long int, vector<long long int>, greater<long long int>> pq;
vector<long long int> adj[N], v;
bool vis[N];
void dfs(long long int s) {
  vis[s] = true;
  v.push_back(s);
  pq.pop();
  for (auto x : adj[s])
    if (!vis[x]) pq.push(x), vis[x] = true;
  if (pq.empty()) return;
  dfs(pq.top());
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, m;
  cin >> n >> m;
  while (m--) {
    long long int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  pq.push(1);
  dfs(1);
  for (auto x : v) cout << x << " ";
  return 0;
}
