Seongwon moves first and Hyeongseok moves second in a board game played on a tree. The board is a tree with N vertices numbered from 1 to N. Vertex 1 is the root node, and the parent child relation is defined with respect to the root. A node without children is called a leaf node.
The two players alternate moving one piece, with Seongwon to move first. At the start, every leaf node holds exactly one piece. On your turn, choose one piece on the board and move it to the parent of the node it stands on. Several pieces may share one node. If the moved piece reaches the root node, remove it from the board at once. After moving, pass the turn to the opponent. A player who cannot choose a piece because the board holds no pieces loses.
Write a program that looks only at the shape of the board and decides whether Seongwon can win with optimal play.