For the May 15 long challenge problem CHEFCK, I created a sparse matrix to create a cache and then process the queries in O(1) time. But it gives me wrong answer for this code. If I try to change from unsigned int to unsigned long long int, it gives Runtime Error. Can anyone help me find what is wrong?

The Sparse Matrix algorithm that I have used is the same logic I used for FRMQ (for which I got AC). FRMQ Sparse Table Algo.