#include <bits/stdc++.h>
using namespace std;
bool ok = true;
stringstream ss;
const int N = (int)2e8 + 11;
vector<int> v[100005];
bool was[100005];
vector<int> ans;
set<int> s;
set<int>::iterator itr;
void dfs(int x) {
  if (s.size() == 0) return;
  itr = s.begin();
  s.erase(itr);
  ans.push_back(x);
  was[x] = true;
  for (int i = 0; i < v[x].size(); i++) {
    int now = v[x][i];
    if (!was[now]) {
      s.insert(now);
    }
  }
  itr = s.begin();
  int b = *itr;
  dfs(b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int from, to;
    cin >> from >> to;
    v[from].push_back(to);
    v[to].push_back(from);
  }
  for (int i = 1; i <= n; i++) {
    sort((v[i]).begin(), (v[i]).end());
  }
  s.insert(1);
  dfs(1);
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
