#include <bits/stdc++.h>
using namespace std;
vector<int> v[100005], ans;
bool vis[100005];
set<int> st;
int main() {
  int n, m, x, y;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  st.insert(1);
  memset(vis, false, sizeof(vis));
  vis[1] = true;
  while ((int)st.size() > 0) {
    x = *st.begin();
    st.erase(*st.begin());
    cout << x << " ";
    for (auto g : v[x]) {
      if (!vis[g]) {
        vis[g] = true;
        st.insert(g);
      }
    }
  }
}
