#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<int> adj[100005];   vector<int> vis(100005, 1);   vector<int> ans;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int T = 1;     for (int qq = 1; qq <= T; qq++) {       cin >> n >> m;       for (int i = 0; i < m; i++) {         int x, y;         cin >> x >> y;         adj[x].push_back(y);         adj[y].push_back(x);       }       priority_queue<int> v;       v.push(-1);       vis[1] = 0;       while (!v.empty()) {         int u = -v.top();         v.pop();         ans.push_back(u);         for (auto i : adj[u])           if (vis[i]) v.push(-i), vis[i] = 0;       }       for (auto i : ans) cout << i <<    ;       cout << endl;     }     return 0;   }   