After watching this video Algorithms Live! Episode 3 — Rolling Hashes and Bloom Filters, I tried to implement pull character from last by myself. I am using 10^9+7 and 10^9+9 as mods. It's giving correct answer for 10^9+7, but giving some weird values for 10^9+9. Can anyone please help finding the problem?
Code : My code