#include using namespace std; int main() { srand(132423); int n, p; cin >> n >> p; vector d(n,0), leaves; for(int i = 0; i < n - 1; ++i) { int u, v; cin >> u >> v; ++d[u], ++d[v]; } for(int i = 0; i < n; ++i){ if(d[i]==1) leaves.push_back(i); } int ans = (leaves.size() + 1) / 2; cout << ans << '\n'; random_shuffle(leaves.begin(), leaves.end()); for(int i = 0; i < ans; ++i) cout << leaves[2*i] << ' ' << leaves[(2*i+1)%n] << '\n'; return 0; }