Python solutions for zoj questions.