#include <bits/stdc++.h>
using namespace std;
long long qpow(long long a, long long b, long long mod) {
  long long r = 1;
  for (; b; b >>= 1) {
    if (b & 1) r = (r * a) % mod;
    a = (a * a) % mod;
  }
  return r;
}
long long C(int n, int m) {
  if (m < n - m) m = n - m;
  long long ans = 1;
  for (int i = m + 1; i <= n; i++) ans *= i;
  for (int i = 1; i <= n - m; i++) ans /= i;
  return ans;
}
const long long mod = 1e9 + 7;
const long long INF = 9e18;
const int inf = 2147483647;
const int N = 1e5 + 5;
priority_queue<int, vector<int>, greater<int> > q;
vector<int> e[N];
vector<int> ans;
int vis[N];
void work() {
  int n, mt;
  scanf("%d%d", &n, &mt);
  for (int i = 0; i < mt; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  vis[1] = 1;
  q.push(1);
  while (q.size()) {
    int d = q.top();
    q.pop();
    ans.push_back(d);
    for (auto &it : e[d]) {
      if (!vis[it]) {
        vis[it] = 1;
        q.push(it);
      }
    }
  }
  for (int i = 0; i < n; i++) printf("%d ", ans[i]);
}
int main() {
  work();
  return 0;
}
