Part of 2018 South Africa National Olympiad
Source: South African Mathematics Olympiad 2018, Problem 6