How to the solve following congruence equations efficiently
$x \equiv k\pmod p$
$a^{x} \equiv k^{-1}*b\pmod p $
where $a$ , $k$ , $b$ are constants and $p$ is a prime number less than $10^{6}$ and $1<a,b<p$
I tried it by first finding smallest $x$ from first equation and iterating for all $x$ less than $p*(p-1)$ such that $a^{x} \equiv k^{-1}*b\pmod p $.But as you can see $p <= 10^{6}$ so $p*(p-1)$ < $10^{12}$.so this is not efficient.So please give any other idea.Thank you.