#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res = (res * x);
    }
    n >>= 1;
    x = (x * x);
  }
  return res;
}
long long powerMOD(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res = (res * x) % 1000000007;
    }
    n >>= 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
int fact(int n) {
  int x = 1, i;
  for (i = n; i >= 2; i--) {
    x = x * i;
  }
  return x;
}
void factors(vector<pair<int, int>> &fac, int n) {
  int i;
  for (i = 1; i < sqrt(n); i++) {
    if (n % i == 0) {
      fac.push_back({i, n / i});
      if ((n / i) != i) {
        fac.push_back({n / i, i});
      }
    }
  }
}
void bipartite(vector<int> a[], int ind, int b[]) {
  int i, j;
  queue<int> c;
  c.push(ind);
  b[ind] = 1;
  while (!c.empty()) {
    j = c.front();
    c.pop();
    for (i = 0; i < a[j].size(); i++) {
      if (b[a[j][i]] == -1) {
        b[a[j][i]] = 1 - b[j];
        c.push(a[j][i]);
      }
    }
  }
  return;
}
vector<int> DFS(vector<int> a[], int b[], int n) {
  int i, j;
  priority_queue<int, vector<int>, greater<int>> d;
  vector<int> c;
  d.push(1);
  while (!d.empty()) {
    j = d.top();
    d.pop();
    c.push_back(j);
    for (auto x : a[j]) {
      if (!b[x]) {
        b[x] = true;
        d.push(x);
      }
    }
  }
  return c;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  int n, m, i, j, k, l;
  cin >> n >> m;
  vector<int> a[n + 1];
  int b[n + 1];
  vector<int> c(n);
  for (i = 0; i < n + 1; i++) {
    b[i] = false;
  }
  for (i = 0; i < m; i++) {
    cin >> l >> k;
    a[l].push_back(k);
    a[k].push_back(l);
  }
  b[1] = true;
  c = DFS(a, b, n);
  for (auto x : c) {
    cout << x << " ";
  }
}
