#include using namespace std; map m; map p; bool root(string s){ //sが親かどうかを返す if(m[s]==s){ p[s]++; return true; } return false; } int main(){ int n; cin >> n; vector a(n); vector b(n); for(int i=0;i> a[i] >> b[i]; m[b[i]]=b[i]; p[b[i]]=0; } for(int i=0;i