#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> g[100005], ans, vis(100005, 0);
set<int> go_to;
void dfs(int i) {
  ans.push_back(i);
  vis[i] = 1;
  for (int v : g[i]) {
    if (!vis[v]) {
      go_to.insert(v);
    }
  }
  if (go_to.size() > 0) {
    int x = *(go_to.begin());
    go_to.erase(x);
    dfs(x);
  }
}
void solve() {
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1);
  for (int x : ans) printf("%d ", x);
  return;
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
