I was solving [this](https://codeforces.net/problemset/problem/1739/C) problem with a combinatoric based approach. So I compute binomial coefficient using Fermat Little Th. and modular inverse. I have correct values for N up to 364, then my code starts giving wrong values. I belive the approach is correct but there is some issue I cant figure out related to modulo, modular inverse or powmod function. Can anybody help me understanding why my code fails? [CODE](https://pastebin.com/rrgCpqHN)