Part of 2019 South Africa National Olympiad
Source: South African Mathematics Olympiad 2019, Problem 3