#include <bits/stdc++.h>
using namespace std;
void BFS(vector<vector<long long> > &graph, long long n,
         vector<long long> &order) {
  vector<long long> vis(n + 1);
  set<long long> PQ;
  PQ.insert(1);
  while (!PQ.empty()) {
    long long x = *PQ.begin();
    PQ.erase(PQ.begin());
    order.push_back(x);
    vis[x] = 1;
    for (long long i = 0; i < graph[x].size(); i++) {
      if (vis[graph[x][i]] == 0) PQ.insert(graph[x][i]);
    }
  }
}
int main() {
  long long n, m, i, j, k, l, w, u, v, t_sum = 0;
  cin >> n >> m;
  vector<vector<long long> > graph(n + 1);
  for (i = 1; i <= m; i++) {
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  vector<long long> order;
  BFS(graph, n, order);
  for (i = 0; i < order.size(); i++) cout << order[i] << " ";
  return 0;
}
