Problem

Source: JBMO Shortlist 2022

Tags: number theory, remainder, prime, Junior, Balkan, shortlist



Find all pairs $(a, p)$ of positive integers, where $p$ is a prime, such that for any pair of positive integers $m$ and $n$ the remainder obtained when $a^{2^n}$ is divided by $p^n$ is non-zero and equals the remainder obtained when $a^{2^m}$ is divided by $p^m$.