Notes

There is a version of this problem based on a read-only interface. This version is more robust with little drawback.