#include <bits/stdc++.h>
using namespace std;
vector<long long int> ans;
set<long long int> v[200005];
bool visited[200005];
void solve() {
  long long int n, m;
  cin >> n >> m;
  for (long long int i = 0; i <= n; ++i) visited[i] = false;
  for (long long int i = 0; i < m; ++i) {
    long long int a, b;
    cin >> a >> b;
    v[a].insert(b);
    v[b].insert(a);
  }
  set<int> can;
  visited[1] = true;
  ans.push_back(1);
  while (ans.size() < n) {
    int p = ans.back();
    for (auto i : v[p])
      if (!visited[i]) can.insert(i);
    ans.push_back(*can.begin());
    visited[*can.begin()] = true;
    can.erase(can.begin());
  }
  for (auto i : ans) cout << i << " ";
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  t = 1;
  while (t--) solve();
  ;
  return 0;
}
