Let me give the solution and clarify where the condition went missing.

Let $k\geq 1$ be such that $f^pq=f^k \mod pq$, and let us show that $k\geq p+q-1$.

It holds that $f^{pq-k}=1 \mod p$ and $f^{pq-k}=1 \mod q$, and thus it must be that $p-1| pq-k$ and $q-1| pq-k$ since $pq-k=p(q-1)+p-k=q(p-1)+q-k$, it follows that $p-1|q-k$ and $q-1|p-k$. Now, here is what we missed: it may be that $k=q$ and $q-1|p-q$, and both equations hold. The assumption that $q-1\not| p-1$ and $p-1\not| q-1$ implies that $p-1\not| q-p$ and also $q-1\not| q-p$, which implies that $k\notin {q,p}$. Now, the latter together with the fact that $p-1|q-k$ and $q-1|p-k$ implies that $|q-k|\geq p-1$ and $|p-k|\geq q-1$. Now you can just put the numbers $p,q,k$ on the real line, according to these two conditions on the distance of $k$ from $p,q$, and see that necessarily $k\geq p+q-1$.

I believe the condition "p-1 does not divide q-1, and q-1 does not divide p-1" should be OK.

In any case, at this point, I suggest not to delve further into the exact fix needed in this question.

Research done at the Technion shows that a glass of red wine would serve you much better!

You have written that for this question it is enough that min(p,q)>2.

But I think it is easy to find a counter example.

Take q=3,p=5,g=h=f=2.

It holds that:

` ``>>> pow(f,p*q,p*q) 8 >>> pow(f,p+q-1,p*q) 8 >>> pow(f,q,p*q) 8`

So the answer to the log would be q, and yet min(p,q)=3>2.

Am I wrong here? (I think you have to require that q-1 doesn't divide p-1, because primes s.t p=2q-1 exist).