#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 7;
vector<int> gr[N];
int n, m;
map<pair<int, int>, int> mp;
vector<int> ans;
int used[N];
set<int> s;
void dfs(int v) {
  used[v] = 1;
  ans.push_back(v);
  for (int to : gr[v]) {
    if (!used[to]) {
      s.insert(to);
    }
  }
  if (!s.empty()) {
    int go = *s.begin();
    s.erase(s.begin());
    dfs(go);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    if (u > v) swap(u, v);
    if (u == v || mp.count({u, v})) continue;
    mp[{u, v}] = 1;
    gr[u].push_back(v);
    gr[v].push_back(u);
  }
  dfs(1);
  for (int to : ans) {
    printf("%d ", to);
  }
}
