input: Write a function to calculate nCr modulo p.
  assert ncr_modp(10,2,13)==6
  assert ncr_modp(15,12,43)==25
  assert ncr_modp(17,9,18)==10
output: def ncr_modp(n, r, p):
      if r > n:
          return 0
      if r == 0 or r == n:
          return 1
      
      fact = [1] * (n + 1)
      for i in range(2, n + 1):
          fact[i] = fact[i - 1] * i % p
      
      inv = [1] * (r + 1)
      inv[r] = pow(fact[r], p - 2, p)
      
      for i in range(r - 1, 0, -1):
          inv[i] = inv[i + 1] * (i + 1) % p
      
      return fact[n] * inv[r] % p * inv[n - r] % p