Source: https://cms.math.ca/Concours/DOCM/examarchive/comc2017-unofficial-solutions-en.pdf