#include <bits/stdc++.h>
using namespace std;
int visi[100000];
vector<set<int>> g;
void edge(int x, int y) {
  if (x != y && g[x].find(y) == g[x].end()) {
    g[x].insert(y);
    g[y].insert(x);
  }
}
void bfs(int s) {
  set<int> q;
  q.insert(s);
  visi[s] = 1;
  while (!q.empty()) {
    set<int>::iterator it = q.begin();
    int x = (*it);
    cout << x << " ";
    q.erase(it);
    set<int>::iterator it2;
    for (it2 = g[x].begin(); it2 != g[x].end(); it2++) {
      if (!visi[(*it2)]) {
        q.insert((*it2));
        visi[(*it2)] = 1;
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  g.assign(n + 1, set<int>());
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    edge(x, y);
  }
  bfs(1);
  return (0);
}
