(0) Obligation:

Q restricted rewrite system:
The TRS R consists of the following rules:

h(X, Z) → f(X, s(X), Z)
f(X, Y, g(X, Y)) → h(0, g(X, Y))
g(0, Y) → 0
g(X, s(Y)) → g(X, Y)

Q is empty.