func_code_string: #include <bits/stdc++.h>   using namespace std;   void bfs(long long root, list<long long> adj[], vector<long long> &level) {     level[root] = 0;     queue<long long> qu;     qu.push(root);     while (!qu.empty()) {       long long cur = qu.front();       qu.pop();       for (auto it : adj[cur]) {         if (level[it] == -1) {           level[it] = level[cur] + 1;           qu.push(it);         }       }     }   }   void solve() {     long long V, E, a, b;     cin >> V >> E;     list<long long> adj[V + 1];     vector<long long> level(V + 1, -1);     for (long long i = 0; i < E; i++) {       cin >> a >> b;       adj[a].push_back(b);       adj[b].push_back(a);     }     bfs(1, adj, level);     map<long long, vector<long long> > mp;     for (int i = 1; i <= V; i++) {       mp[level[i]].push_back(i);     }     a = mp.size();     vector<long long> ans1, ans2;     for (int i = 0; i < a; i += 2) {       vector<long long> hold = mp[i];       for (auto it : hold) ans1.push_back(it);     }     for (int i = 1; i < a; i += 2) {       vector<long long> hold = mp[i];       for (auto it : hold) ans2.push_back(it);     }     if (ans1.size() < ans2.size()) {       cout << ans1.size() << endl;       for (auto it : ans1) cout << it <<    ;       cout << endl;     } else {       cout << ans2.size() << endl;       for (auto it : ans2) cout << it <<    ;       cout << endl;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long q = 1;     cin >> q;     while (q--) {       solve();     }     return 0;   }   