# Baby-step giant-step algorithm

I have equation in form $a^x = p (\textrm{mod q})$, knowing $p, q, a$. I have to use Shank's algorithm (Baby-step giant-step).

I found some exercise and explanation on http://www.numbertheory.org/courses/MP313/lectures/lecture8/page4.gif and http://www.numbertheory.org/courses/MP313/lectures/lecture8/page5.jpg.

I do not understand a few things.

• how to determine $Q$?
• how can I get the table with Test $8\times 6^{-i}$?

Thanks for any advice and explanation.

-