#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
vector<int> G[maxn];
bool vis[maxn];
queue<int> que;
priority_queue<int, vector<int>, greater<int> > que1;
int n, m;
void bfs(int root) {
  int num = 1;
  vis[1] = 1;
  que1.push(1);
  while (num <= n) {
    int u = que1.top();
    que1.pop();
    que.push(u);
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      if (!vis[v]) {
        que1.push(v);
        vis[v] = 1;
      }
    }
    if (num > n) break;
    num++;
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  bfs(1);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    printf("%d ", u);
  }
}
