#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector<int> g[maxn];
bool used[maxn];
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) used[i] = true;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<int> res;
  set<int> cur;
  cur.insert(0);
  while (cur.size()) {
    auto it = *cur.begin();
    res.push_back(it);
    used[it] = false;
    for (int u : g[it]) {
      if (!used[u]) continue;
      cur.insert(u);
    }
    cur.erase(it);
  }
  for (int x : res) cout << x + 1 << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  int test;
  test = 1;
  for (int tst = 1; tst <= test; ++tst) {
    solve();
  }
  return 0;
}
