String Hashing Problem - SSTORY

I am getting Wrong Answer for my solution of this problem -

My solution -

My solution is working within time for large testcases that I generated and giving correct answer for small testcases. Can someone please help me find out some testcases where my solution is wrong or possible pitfalls in my solution?

I have used a rolling hash + binary search (as mentioned in the editorial).