Please help me understand as to what is it that I am doing wrong here.
Please help me understand what is it that I am doing wrong here
hello @indrabijaynarayan
u are not taking modulo of the answer

a) also while performing addition use modulo property.
(a+b)%mod=(a%mod+b%mod)%mod
after doing above changes your code will work.
for some space optimisation
1d array will be sufficient for the problem. because m is always fixed.