#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m;
vector<int> E[N];
int ans[N], c;
bool vis[N];
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; i++) E[i].clear();
    while (m--) {
      int u, v;
      scanf("%d%d", &u, &v);
      E[u].push_back(v);
      E[v].push_back(u);
    }
    for (int i = 1; i <= n; i++) sort(E[i].begin(), E[i].end());
    memset(vis, 0, sizeof(vis));
    c = 0;
    priority_queue<int, vector<int>, greater<int> > q;
    q.push(1);
    vis[1] = 1;
    while (!q.empty()) {
      int u = q.top();
      q.pop();
      ans[c++] = u;
      for (int i = 0; i < E[u].size(); i++)
        if (!vis[E[u][i]]) q.push(E[u][i]), vis[E[u][i]] = 1;
    }
    for (int i = 1; i <= n; i++)
      if (!vis[i]) ans[c++] = i;
    for (int i = 0; i < n; i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
