#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int n, m;
vector<int> dc[maxn + 1];
priority_queue<int, vector<int>, greater<int> > q;
bool dt[maxn + 1];
void nhap() {
  cin >> n >> m;
  int i;
  for (i = 1; i <= m; i = i + 1) {
    int x, y;
    cin >> x >> y;
    dc[x].push_back(y);
    dc[y].push_back(x);
  }
}
void xu_ly() {
  int i;
  for (i = 1; i <= n; i = i + 1) {
    dt[i] = false;
  };
  while (!q.empty()) {
    q.pop();
  };
  q.push(1);
  dt[1] = true;
  while (!q.empty()) {
    int x;
    x = q.top();
    q.pop();
    cout << x << " ";
    int sld;
    sld = dc[x].size();
    int i;
    for (i = 0; i <= sld - 1; i = i + 1) {
      int y;
      y = dc[x].at(i);
      if (dt[y] == false) {
        q.push(y);
        dt[y] = true;
      }
    }
  }
}
int main() {
  nhap();
  xu_ly();
}
