Solved Sherlock and the Beast .java & .py