Part of 2017 Lusophon Mathematical Olympiad
Source: VII Lusophon Mathematical Olympiad 2017 - Problem 6