We define the value of an unrooted tree T as ∑u∈V2sum_{u in V} ^2∑u∈V2, where V is the set of all vertices of T, and d is the degree of the vertex u. We define the value of a forest as the sum of the value of all trees from it. Now we want you to answer the sum of the value of all forests with N labeled vertices. In order to avoid calculations of huge integers, report answer modulo a prime M instead.
We define the value of an unrooted tree T as ∑u∈V(T)(d(u))2sum_{u in V(T)} (d(u))^2∑u∈V(T)(d(u))2, where V(T) is the set of all vertices of T, and d(u) is the degree of the vertex u. We define the value of a forest as the sum of the value of all trees from it. Now we want you to answer the sum of the value of all forests with N labeled vertices. In order to avoid calculations of huge integers, report answer modulo a prime M instead.
(图片来源网络,侵删)