#include <bits/stdc++.h>
using namespace std;
int vis[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  vector<int> s[100001];
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < k; i++) {
    int x, y;
    cin >> x >> y;
    s[x].push_back(y);
    s[y].push_back(x);
  }
  priority_queue<int, vector<int>, greater<int> > pq;
  pq.push(1);
  vector<int> v;
  while (!(pq.empty())) {
    long long a = pq.top();
    pq.pop();
    v.push_back(a);
    vis[a] = true;
    for (int i = 0; i < s[a].size(); i++) {
      if (!vis[s[a][i]]) {
        pq.push(s[a][i]);
        vis[s[a][i]] = 1;
      }
    }
  }
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
}
