input: Write a python function to calculate n choose r modulo p.
  assert ncr_modulo_p(10, 2, 13) == 6
  assert ncr_modulo_p(15, 12, 43) == 25
  assert ncr_modulo_p(17, 9, 18) == 10
output: def ncr_modulo_p(n, r, p):
      if r > n:
          return 0
      if r == 0 or r == n:
          return 1
      
      numerator = 1
      for i in range(r):
          numerator = (numerator * (n - i)) % p
      
      denominator = 1
      for i in range(1, r + 1):
          denominator = (denominator * i) % p
      
      def mod_inverse(a, p):
          return pow(a, p - 2, p)
      
      return (numerator * mod_inverse(denominator, p)) % p