#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
vector<int> adjList[n];
for(int i=0;i<n-1;i++){
int x,y;
cin>>x>>y;
adjList[x].push_back(y);
adjList[y].push_back(x);
}
for(int i=0;i<n;i++){
if(adjList[i].size()<=2){
cout<<i<<" ";
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCBuOwoJY2luPj5uOwoJdmVjdG9yPGludD4gYWRqTGlzdFtuXTsKCWZvcihpbnQgaT0wO2k8bi0xO2krKyl7CgkJaW50IHgseTsKCQljaW4+Png+Pnk7CgkJYWRqTGlzdFt4XS5wdXNoX2JhY2soeSk7CgkJYWRqTGlzdFt5XS5wdXNoX2JhY2soeCk7Cgl9Cglmb3IoaW50IGk9MDtpPG47aSsrKXsKCQlpZihhZGpMaXN0W2ldLnNpemUoKTw9Mil7CgkJCWNvdXQ8PGk8PCIgIjsKCQl9Cgl9CglyZXR1cm4gMDsKfQ==