#include <bits/stdc++.h>
using namespace std;
void autoinput() {
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
}
const long long mod = (998244353);
long long bigmod(long long N, long long P) {
  if (P == 0) return 1;
  if (P % 2 == 0) {
    long long ret = bigmod(N, P / 2);
    return ((ret % mod) * (ret % mod)) % mod;
  } else
    return ((N % mod) * (bigmod(N, P - 1) % mod)) % mod;
}
std::vector<long long> v[100005];
bool visited[100005];
int main() {
  long long i, j, k, l, m, n, w;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> j >> k;
    v[j].push_back(k);
    v[k].push_back(j);
  }
  priority_queue<long long, vector<long long>, greater<long long> > pq;
  pq.push(1);
  visited[1] = 1;
  std::vector<long long> ans;
  while (!pq.empty()) {
    long long u = pq.top();
    ans.push_back(u);
    pq.pop();
    for (auto it : v[u]) {
      if (!visited[it]) {
        visited[it] = 1;
        pq.push(it);
      }
    }
  }
  for (auto it : ans) cout << it << " ";
}
