#include <bits/stdc++.h>
using namespace std;
vector<bool> visited;
set<int> can_go;
vector<int> ans;
vector<vector<int>> graph;
void dfs(int v) {
  visited[v] = true;
  for (int i = 0; i < graph[v].size(); i++) {
    if (!visited[graph[v][i]]) {
      can_go.insert(graph[v][i]);
    }
  }
  if (can_go.empty()) {
    return;
  }
  int to = *can_go.begin();
  can_go.erase(can_go.begin());
  ans.push_back(to + 1);
  dfs(to);
}
int main() {
  int n, m;
  cin >> n >> m;
  graph.resize(n);
  visited.resize(n, false);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    graph[x - 1].push_back(y - 1);
    graph[y - 1].push_back(x - 1);
  }
  ans.push_back(1);
  dfs(0);
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
