Problem

Source: 2018 JBMO TST- Macedonia

Tags: Junior, Macedonia, JMMO, 2018, number theory



Determine all pairs $(p, q)$, $p, q \in \mathbb {N}$, such that $(p + 1)^{p - 1} + (p - 1)^{p + 1} = q^q$.