#include <bits/stdc++.h>
using namespace std;
set<int> st;
set<int>::iterator it;
struct node {
  int to, nxt;
} edge[100000 * 8 + 10];
int cnt, head[100000 + 10], vis[100000 + 10];
void add(int u, int v) {
  edge[cnt].to = v;
  edge[cnt].nxt = head[u];
  head[u] = cnt++;
}
int main() {
  int n, m;
  cin >> n >> m;
  memset(head, -1, sizeof head);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    add(x, y);
    add(y, x);
  }
  st.insert(1);
  while (!st.empty()) {
    it = st.begin();
    int rt = *it;
    cout << rt << " ";
    vis[rt] = 1;
    st.erase(st.begin());
    for (int i = head[rt]; ~i; i = edge[i].nxt) {
      if (vis[edge[i].to] == 0) {
        st.insert(edge[i].to);
        vis[edge[i].to] = 1;
      }
    }
  }
  cout << endl;
  return 0;
}
