Codeforces Round #177 Problem D Polo the Penguin and Trees