SPOJ Is It A Tree