Implemented in Java
Implemented in Python