(0) Obligation:

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

p(f(f(x))) → q(f(g(x)))
p(g(g(x))) → q(g(f(x)))
q(f(f(x))) → p(f(g(x)))
q(g(g(x))) → p(g(f(x)))

Q is empty.