#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
ll mod_pow(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
ll mod_inverse(ll a) { return mod_pow(a, 1000000007 - 2); }
const int N = 100005;
vector<vector<int>> a(N);
vector<int> seq;
void bfs() {
  int vis[N]{};
  priority_queue<int, vector<int>, greater<int>> q;
  q.push(1);
  vis[1] = 1;
  while (!q.empty()) {
    int tm = q.top();
    q.pop();
    seq.push_back(tm);
    for (auto u : a[tm]) {
      if (!vis[u]) {
        vis[u] = 1;
        q.push(u);
      }
    }
  }
}
void solve() {
  int n, m, x, y;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  bfs();
  for (auto u : seq) {
    cout << u << " ";
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
