You are given a rooted undirected tree consisting of nn vertices. Vertex 11 is the root. Let's denote a depth array of vertex xx as an infinite sequence [dx,0,dx,1,dx,2,…][dx,0,dx,1,dx,2,…], where dx,idx,i is the number of vertices yy such that both…