#include #include using namespace std; int father[100010]; int findfather(int x) { while (father[x]!=x) x=father[x]; return x; } bool is_father(int m,int n) { while (father[m]!=n) { if (father[m]==m) return true; m=father[m]; } return false; } int main() { bool e,flag; int times=0; int maxx,root,m,n,t; while (cin >> m >> n && (m>=0 && n>=0)) { memset(father,0,sizeof(father)); e=false;flag=true; root=-1; maxx=0; while ((m+n)!=0) { if (e) cin >> m >> n; if (m+n==0) break; if (maxx