Let $p$ be the largest prime less than $2013$ for which \[ N = 20 + p^{p^{p+1}-13} \] is also prime. Find the remainder when $N$ is divided by $10^4$.

Let's think step by step and output the final answer within \boxed{}.
user