#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long vis[100005];
vector<long long> g[100005];
set<long long> S;
void dfs(long long x) {
  cout << x << " ";
  vis[x] = 1;
  S.erase(x);
  for (long long y : g[x]) {
    if (!vis[y]) {
      S.insert(y);
    }
  }
  if (!S.empty()) {
    dfs(*S.begin());
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1);
  return 0;
}
