#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> G[100010];
priority_queue<int, vector<int>, greater<int> > q;
int vis[100010];
int ans[100010];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  q.push(1);
  vis[1] = 1;
  for (int i = 1; i <= n; ++i) {
    int x = q.top();
    q.pop();
    cout << x << ' ';
    for (int j = 0; j < G[x].size(); ++j) {
      int y = G[x][j];
      if (!vis[y]) {
        vis[y] = 1;
        q.push(y);
      }
    }
  }
  return 0;
}
