Codeforces Beta Round #54 Problem C Trees