#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f;
using namespace std;
priority_queue<int, vector<int>, greater<int> > a[100005], p;
int vis[100005];
queue<int> s;
int n, m;
void fun() {
  p.push(1);
  vis[1] = 1;
  s.push(1);
  while (p.size()) {
    int t = p.top();
    p.pop();
    if (!vis[t]) {
      s.push(t);
      vis[t] = 1;
    }
    while (a[t].size()) {
      int f = a[t].top();
      a[t].pop();
      if (!vis[f]) {
        p.push(f);
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  int x, y;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    a[x].push(y);
    a[y].push(x);
  }
  fun();
  while (s.size()) {
    printf("%d ", s.front());
    s.pop();
  }
  return 0;
}
