code: def dmp_rr_div(f, g, u, K):
      """
      Multivariate division with remainder over a ring.
  
      Examples
      ========
  
      >>> from sympy.polys import ring, ZZ
      >>> R, x,y = ring("x,y", ZZ)
  
      >>> R.dmp_rr_div(x**2 + x*y, 2*x + 2)
      (0, x**2 + x*y)
  
      """
      if not u:
          return dup_rr_div(f, g, K)
  
      df = dmp_degree(f, u)
      dg = dmp_degree(g, u)
  
      if dg < 0:
          raise ZeroDivisionError("polynomial division")
  
      q, r, dr = dmp_zero(u), f, df
  
      if df < dg:
          return q, r
  
      lc_g, v = dmp_LC(g, K), u - 1
  
      while True:
          lc_r = dmp_LC(r, K)
          c, R = dmp_rr_div(lc_r, lc_g, v, K)
  
          if not dmp_zero_p(R, v):
              break
  
          j = dr - dg
  
          q = dmp_add_term(q, c, j, u, K)
          h = dmp_mul_term(g, c, j, u, K)
          r = dmp_sub(r, h, u, K)
  
          _dr, dr = dr, dmp_degree(r, u)
  
          if dr < dg:
              break
          elif not (dr < _dr):
              raise PolynomialDivisionFailed(f, g, K)
  
      return q, r
  
imports: from sympy.polys.densebasic import dup_slice, dup_LC, dmp_LC, dup_degree, dmp_degree, dup_strip, dmp_strip, dmp_zero_p, dmp_zero, dmp_one_p, dmp_one, dmp_ground, dmp_zeros
  from sympy.polys.polyerrors import ExactQuotientFailed, PolynomialDivisionFailed
label_desc: Use image node_id 46 for calling a global function with example usage: dmp_rr_div(f, g, u, K) and returns: q,  r, dup_rr_div, q,  r