Source: https://www.imo-official.org/problems/IMO2014SL.pdf