you give rooted tree consist n vertex number 1 n the root tree vertex 1you color vertex tree n color number 1 n exactly vertex color let c_i color vertex p_i parent vertex root tree the coloring consider beautiful vertex k k 1 c_k c_p_k 1 ie vertex color color parent exactly 1calculate number beautiful coloring print modulo 998244353