Codeforces Beta Round #29 Problem D Ant on the Tree