Source: https://www.cemc.uwaterloo.ca/contests/past_contests/2020/2020BCCContestSolutions9_10.pdf