Why am I getting TLE in this SPOJ problem?

Hi there, I am trying to solve this problem with sparse table, I am getting TLE on this problem.

Here is what I tried.

Thanks in advance.

Anyone on this?