#include <bits/stdc++.h>
using namespace std;
vector<long long int> graph[100001];
bool vis[100001];
vector<long long int> ans;
void dfs(long long int root) {
  vis[root] = true;
  ans.push_back(root);
  sort(graph[root].begin(), graph[root].end());
  for (int i = 0; i < graph[root].size(); i++) {
    if (!vis[graph[root][i]]) dfs(graph[root][i]);
  }
}
void solve() {
  long long int a, b, c, d, i, j, k, l;
  cin >> a >> b;
  for (i = 0; i < b; i++) {
    cin >> c >> d;
    graph[c].push_back(d);
    graph[d].push_back(c);
  }
  memset(vis, false, sizeof(vis));
  map<int, int> m;
  m[1] = 0;
  while (m.size()) {
    k = m.begin()->first;
    m.erase(k);
    ans.push_back(k);
    vis[k] = true;
    for (i = 0; i < graph[k].size(); i++) {
      if (!vis[graph[k][i]]) {
        m[graph[k][i]] = 0;
      }
    }
  }
  for (i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}
int main() {
  int t = 1;
  while (t--) solve();
}
