#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
vi adj[100005];
bool visited[100005];
void solve() {
  int n, m;
  cin >> n >> m;
  for (ll i = 0; i < (m); i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  priority_queue<int, vector<int>, greater<int>> q;
  q.push(0);
  while (!q.empty()) {
    int second = q.top();
    q.pop();
    visited[second] = true;
    cout << second + 1 << " ";
    for (int u : adj[second]) {
      if (visited[u]) continue;
      visited[u] = true;
      q.push(u);
    }
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
}
