#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
priority_queue<int, vector<int>, greater<int> > que;
vector<int> a[maxn];
int vis[maxn], n, m;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  que.push(1);
  while (!que.empty()) {
    int u = que.top();
    que.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    cout << u << " ";
    for (int i = 0; i < a[u].size(); i++) {
      if (!vis[a[u][i]]) que.push(a[u][i]);
    }
  }
  return 0;
}
