you give tree connect undirected graph cycle n vertex each n 1 edge tree color black redyou give integer k Consider sequence k vertex Lets sequence a_1 a_2 ldot a_k good satisfie follow criterion we walk path possibly visit edgevertex multiple time tree start a_1 end a_k Start a_1 a_2 short path a_1 a_2 a_3 similar way travel short path a_k1 a_k if walk black edge process sequence good consider tree picture if k3 follow sequence good 1 4 7 5 5 3 2 3 7 the follow sequence good 1 4 6 5 5 5 3 7 3there nk sequence vertex count good since number large print modulo 1097