#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > sf(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    sf[x].push_back(y);
    sf[y].push_back(x);
  }
  vector<bool> used(n, true);
  set<int> mei;
  vector<int> ans;
  mei.insert(0);
  while (mei.size() > 0) {
    set<int>::iterator it = mei.begin();
    int v = *it;
    used[v] = false;
    ans.push_back(v);
    mei.erase(mei.begin());
    for (int i = 0; i < sf[v].size(); i++) {
      int g = sf[v][i];
      if (used[g]) {
        mei.insert(g);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] + 1 << " ";
  }
}
