#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 5;
int n, m;
vector<int> g[N];
void code() {
  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);
  }
  vector<int> vis(n + 1, 0);
  set<int> se;
  se.insert(1);
  while (se.size()) {
    int x = *se.begin();
    se.erase(x);
    vis[x] = 1;
    cout << x << " ";
    for (auto j : g[x]) {
      if (!vis[j]) se.insert(j);
    }
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t = 1;
  while (t-- > 0) {
    code();
  }
}
