#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
vector<long long> adj[1000007];
int vis[1000007] = {0};
int dist[1000007] = {0};
vector<long long> ans;
void dfs(long long x) {
  vis[x] = 1;
  ans.push_back(x);
  for (auto e : adj[x]) {
    if (!vis[e]) {
      dfs(e);
    }
  }
}
int main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  set<long long> s;
  vis[1] = 1;
  s.insert(1);
  while (s.size()) {
    auto it = s.begin();
    long long x = *it;
    ans.push_back(*it);
    vis[*it] = 1;
    s.erase(it);
    for (auto it1 : adj[x]) {
      if (vis[it1] == 0) {
        s.insert(it1);
        vis[it1] = 1;
      }
    }
  }
  for (long long i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  ;
  return 0;
}
