implemented in Java for 5. Coding Contest