#include <bits/stdc++.h>
using namespace std;
long double pi = 3.14159265358979323;
const double EPS = 1e-12;
const int N = 1e6 + 5;
const int mod = 998244353;
vector<long long> v[N];
bool vis[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long a, b;
  while (m--) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  set<long long> s;
  s.insert(1);
  vis[1] = 1;
  while (!s.empty()) {
    int x = *s.begin();
    cout << x << " ";
    auto it = s.begin();
    s.erase(it);
    for (auto it : v[x]) {
      if (!vis[it]) {
        s.insert(it);
        vis[it] = 1;
      }
    }
  }
  return 0;
}
