topcoder; solve "IdentifyingWood" from SRM #635