#include <bits/stdc++.h>
using namespace std;
vector<int> ans;
vector<int> G[100005];
std::priority_queue<int, std::vector<int>, std::greater<int> > q;
int topMostParent(int v, int* parent) {
  if (parent[v] == v) {
    return v;
  }
  return topMostParent(parent[v], parent);
}
int vis[100005];
void dfs(int u) {
  vis[u] = 1;
  ans.push_back(u);
  for (auto v : G[u]) {
    q.push(v);
  }
  while (!q.empty()) {
    int v = q.top();
    q.pop();
    if (!vis[v]) dfs(v);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1);
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
