#include <bits/stdc++.h>   using namespace std;   vector<long long> graph[200010];   long long v[200010], new_visit[200010], MAX_node, mx, cnt;   void dfs(long long node) {     v[node] = 1;     if ((long long)graph[node].size() > mx) {       mx = (long long)graph[node].size();       MAX_node = node;     }     for (auto &x : graph[node])       if (!v[x]) dfs(x);   }   void bfs(long long node) {     queue<long long> q;     q.push(node);     while (!q.empty()) {       long long frt = q.front();       new_visit[frt] = 1;       q.pop();       for (auto &x : graph[frt]) {         if (!new_visit[x]) {           new_visit[x] = 1;           cout << frt <<     << x << endl;           q.push(x);           cnt--;           if (cnt == 0) return;         }       }     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, m;     cin >> n >> m;     cnt = n - 1;     for (long long i = 0; i < m; i++) {       long long x, y;       cin >> x >> y;       graph[x].push_back(y);       graph[y].push_back(x);     }     dfs(1);     bfs(MAX_node);   }   