#include using namespace std; int main(){ int n; cin>>n; vector ls[n]; int x,y; for(int i=1;i>x>>y; x--; y--; ls[x].push_back(y); ls[y].push_back(x); } vector ans(n,(1<<30)); queue q; ans[0]=0,q.push(0); for(int i=1;ians[now]+1){ ans[next]=ans[now]+1; q.push(next); } } } for(int i=0;i