If 2∣pq, we suppose that p=2 without loss of generality, and then q∣5q+25. By Fermat's theorem we have q∣5q−5, so q∣30, where (2,3) and (2,5) are solutions [(2, 2) does not fit].
If 5∣pq, we suppose that p=5 without loss of generality and then 5q∣5q+55. By Fermat's theorem we have q∣55q−1, so q∣313, where (5,5) and (5,313) are solutions.
Otherwise, we have pq∣5p−1+5q−1, and so
5p−1+5q−1≡0(modp).
By Fermat's theorem, 5p−1≡1(modp),
and because of the above, 5q−1≡−1(modp).
Denote by p−1=2k(2r−1), q−1=2l(2s−1), where k,l,r,s are positive integers.
If k≤l, because of the previous congruences we get
1=12l−k(2s−1)≡(5p−1)2l−k(2s−1)=52l(2r−1)(2s−1)=(5q−1)2r−1=(−1)2r−1=−1(modp),
a contradiction of p=2. So k>l.
But we have k<l by a similar argument — a contradiction.
Therefore, all possible pairs of primes (p,q) are (2,3), (3,2), (2,5), (5,2), (5,5), (5,313) and (313,5).