#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
set<int> S;
vector<int> E[N];
int vis[N], n, m;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    E[x].push_back(y);
    E[y].push_back(x);
  }
  S.insert(1);
  vis[1] = 1;
  while (!S.empty()) {
    int x = *S.begin();
    S.erase(S.begin());
    for (int R : E[x])
      if (!vis[R]) S.insert(R), vis[R] = 1;
    printf("%d ", x);
  }
}
