Regarding the Rabin Karp Matching Algorithm Code

My code is same as the one shown in video and works for the Test Case shown in the video, but doesn’t works for different testcases.Example testcase for which it doesn’t works is
ababcabdab
abc
.The link for my code is https://code.hackerearth.com/3d21e6Q?key=9885f327b578fc6c3ad5c20ee37fcef4