#include <bits/stdc++.h>   using namespace std;   priority_queue<int, vector<int>, greater<int> > p;   bool visited[100005];   vector<int> G[100005];   int n, m;   void prime() {     p.push(1);     while (!p.empty()) {       int v = p.top();       p.pop();       if (visited[v]) continue;       visited[v] = true;       printf( %d  , v);       for (int i = 0; i < G[v].size(); i++) {         if (!visited[G[v][i]]) p.push(G[v][i]);       }     }   }   int main() {     scanf( %d%d , &n, &m);     int x, y;     for (int i = 0; i < m; i++) {       scanf( %d%d , &x, &y);       G[x].push_back(y);       G[y].push_back(x);     }     memset(visited, false, sizeof(visited));     prime();     return 0;   }   