We have a forest of rooted trees. Two players makes alternating moves according to the following rule: one move is to cut vertex and all its children. Player which makes last move (no vertices remain) wins.
How can we compute Grundy function for the positions in the game?
Suppose we have a trees and we need to say whether current position is winning or losing?