code: def dmp_zz_modular_resultant(f, g, p, u, K):
      """
      Compute resultant of `f` and `g` modulo a prime `p`.
  
      Examples
      ========
  
      >>> from sympy.polys import ring, ZZ
      >>> R, x,y = ring("x,y", ZZ)
  
      >>> f = x + y + 2
      >>> g = 2*x*y + x + 3
  
      >>> R.dmp_zz_modular_resultant(f, g, 5)
      -2*y**2 + 1
  
      """
      if not u:
          return gf_int(dup_prs_resultant(f, g, K)[0] % p, p)
  
      v = u - 1
  
      n = dmp_degree(f, u)
      m = dmp_degree(g, u)
  
      N = dmp_degree_in(f, 1, u)
      M = dmp_degree_in(g, 1, u)
  
      B = n * M + m * N
  
      D, a = [K.one], -K.one
      r = dmp_zero(v)
  
      while dup_degree(D) <= B:
          while True:
              a += K.one
  
              if a == p:
                  raise HomomorphismFailed("no luck")
  
              F = dmp_eval_in(f, gf_int(a, p), 1, u, K)
  
              if dmp_degree(F, v) == n:
                  G = dmp_eval_in(g, gf_int(a, p), 1, u, K)
  
                  if dmp_degree(G, v) == m:
                      break
  
          R = dmp_zz_modular_resultant(F, G, p, v, K)
          e = dmp_eval(r, a, v, K)
  
          if not v:
              R = dup_strip([R])
              e = dup_strip([e])
          else:
              R = [R]
              e = [e]
  
          d = K.invert(dup_eval(D, a, K), p)
          d = dup_mul_ground(D, d, K)
          d = dmp_raise(d, v, 0, K)
  
          c = dmp_mul(d, dmp_sub(R, e, v, K), v, K)
          r = dmp_add(r, c, v, K)
  
          r = dmp_ground_trunc(r, p, v, K)
  
          D = dup_mul(D, [K.one, -a], K)
          D = dup_trunc(D, p, K)
  
      return r
  
imports: from sympy.polys.densearith import dup_sub_mul, dup_neg, dmp_neg, dmp_add, dmp_sub, dup_mul, dmp_mul, dmp_pow, dup_div, dmp_div, dup_rem, dup_quo, dmp_quo, dup_prem, dmp_prem, dup_mul_ground, dmp_mul_ground, dmp_mul_term, dup_quo_ground, dmp_quo_ground, dup_max_norm, dmp_max_norm
  from sympy.polys.densebasic import dup_strip, dmp_raise, dmp_zero, dmp_one, dmp_ground, dmp_one_p, dmp_zero_p, dmp_zeros, dup_degree, dmp_degree, dmp_degree_in, dup_LC, dmp_LC, dmp_ground_LC, dmp_multi_deflate, dmp_inflate, dup_convert, dmp_convert, dmp_apply_pairs
  from sympy.polys.densetools import dup_clear_denoms, dmp_clear_denoms, dup_diff, dmp_diff, dup_eval, dmp_eval, dmp_eval_in, dup_trunc, dmp_ground_trunc, dup_monic, dmp_ground_monic, dup_primitive, dmp_ground_primitive, dup_extract, dmp_ground_extract
  from sympy.polys.galoistools import gf_int, gf_crt
  from sympy.polys.polyconfig import query
  from sympy.polys.polyerrors import MultivariatePolynomialError, HeuristicGCDFailed, HomomorphismFailed, NotInvertible, DomainError
label_desc: Use image node_id 18 for calling a global function with example usage: dmp_zz_modular_resultant(f, g, p, u, K) and returns: r, gf_int