#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, m, a, b;
vector<int> graf[maxn];
bool bio[maxn];
queue<int> sol;
void solve() {
  priority_queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int temp = -q.top();
    q.pop();
    if (bio[temp]) continue;
    bio[temp] = true;
    sol.push(temp);
    for (int i = 0; i < graf[temp].size(); i++) {
      if (!bio[graf[temp][i]]) q.push(-graf[temp][i]);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    graf[a].push_back(b);
    graf[b].push_back(a);
  }
  solve();
  while (!sol.empty()) {
    cout << sol.front() + 1 << " ";
    sol.pop();
  }
  return 0;
}
