Part of 2018 239 Open Mathematical Olympiad
Source: 239 Open MO, 2018, Junior League, Problem 3, Senior League, Problem 2