#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
const int MOD = 1e9 + 7;
int n, m;
vector<int> g[N];
set<int> q;
bool used[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) used[i] = false;
  q.insert(1);
  for (int i = 1; i <= n; i++) {
    int v = (*q.begin());
    used[v] = true;
    q.erase(q.begin());
    printf("%d ", v);
    for (int u : g[v]) {
      if (!used[u]) q.insert(u);
    }
  }
  return 0;
}
