I'm given three numbers $e,d_1,d_2\in \mathbb{N}$ where: \begin{align} e\cdot d_1 &\equiv 1 \pmod {(p-1)(q-1)}\\ e\cdot d_2 &\equiv 1 \pmod {(p-1)(r-1)} \end{align} Where $p,q,r$ are unknown primes.
Does there exist an efficient way of finding any of the primes?
My first though was calculating $(p-1)(q-1)=e\cdot d_1-1=n_1$ and $(p-1)(r-1)=e\cdot d_2-1=n_2$ and then finding $p=\gcd(n_1,n_2)+1$, but this obviously doesn't work since $p-1$ isn't prime.
Any help is much appriciated.