PLZ EXPLAIN BABY - STEP GIANT-STEP ALGORITHM

Can someone explain me in detail the algorithm BABY - STEP GIANT-STEP which i came to know by seeing this problem https://www.hackerearth.com/problem/algorithm/dexter-plays-with-gp-1/description/

I tried in various tutorials but unable to understand.

Thank You!

see this …https://e-maxx.ru/algo/discrete_log

Thansk @avi892nash.I am unaable to understand the implementation part.If you don’t mind can you spare some time.

//