#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
priority_queue<int, vector<int>, greater<int> > q;
int n, m;
bool vis[maxn];
vector<int> E[maxn];
void pp(int now) {
  for (int i = 0; i < E[now].size(); i++) {
    if (!vis[E[now][i]]) q.push(E[now][i]), vis[E[now][i]] = true;
  }
}
int main() {
  int x, y;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    if (x == y) continue;
    E[x].push_back(y);
    E[y].push_back(x);
  }
  q.push(1);
  vis[1] = true;
  for (int i = 1; i <= n; i++) {
    int now = q.top();
    q.pop();
    printf("%d ", now);
    pp(now);
  }
}
