#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
vector<int> adj[N];
bool vis[N];
void DFS(int p = 1) {
  priority_queue<int> st;
  st.push(p * -1);
  vis[p] = 1;
  while (!st.empty()) {
    int p = st.top() * -1;
    printf("%d ", p);
    st.pop();
    for (int ch : adj[p]) {
      if (!vis[ch]) st.push(ch * -1);
      vis[ch] = 1;
    }
  }
}
int main() {
  int test = 1;
  while (test--) {
    int n, m;
    scanf("%d", &n);
    scanf("%d", &m);
    while (m--) {
      int u, v;
      scanf("%d", &u);
      scanf("%d", &v);
      adj[v].push_back(u);
      adj[u].push_back(v);
    }
    DFS();
  }
}
