Yuu Koito Touko Nanami newlywed on wedding day Yuu gift Touko direct tree n node root 1 labeling DFS order tree every edge tree direct away rootafter call dfs1 follow algorithm return DFS order tree root 1 order 0a array length n function dfsu order order 1 au order v direct edge u v dfsvNote different DFS order give treeTouko like present decide play on day follow wedding day Touko perform procedure among directed edge u rightarrow v a_u a_v select edge u rightarrow v lexicographically small pair a_u a_v swap a_u a_vday pass wedding Touko forget date wed original labeling Fearing Yuu angry Touko decide ask derive piece information current labelingbee good friend need find number day pass wedding original labeling tree however chance Touko mess procedure result current labeling impossible obtain original labeling case inform Touko