Regarding the question

Hi ,
I tried solving the question on my own however i am getting a few errors as well as wrong answer for the testcase.

Kindly help me with the code

The link is as follow

The input case is mentioned as follows

1 1 -> first k terms , 1 1 -> coeff of recursive relation , m ->2 ,n->10 ,p=1000003

@imsharan0105
Will get back to you asap.

@imsharan0105

Try solving it this way. Find the sum of the first n terms and then find the sum of first (m - 1) terms. Their difference is the answer. This can be done by appending a variable which stores the sum of all the terms till the nth term in the b matrix. Also you will have to modify the T matrix.
Please revert if you face any issue.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.