#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 3;
const int mod = 1e8 + 7;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const int pw = 257;
int n, m;
bool u[N];
set<int> s;
vector<int> g[N];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  u[1] = 1;
  s.insert(1);
  while (n--) {
    int cur = (*s.begin());
    cout << cur << ' ';
    s.erase(cur);
    for (auto to : g[cur]) {
      if (!u[to]) {
        u[to] = 1;
        s.insert(to);
      }
    }
  }
  return 0;
}
