human
Complete this python program:
def TR22(rv, max=4, pow=False):
assistant
#Here is the Python program you requested.

    """Convert tan(x)**2 to sec(x)**2 - 1 and cot(x)**2 to csc(x)**2 - 1.
    See _TR56 docstring for advanced use of ``max`` and ``pow``.
    Examples
    >>> from sympy.simplify.fu import TR22
    >>> from sympy.abc import x
    >>> from sympy import tan, cot
    >>> TR22(1 + tan(x)**2)
    sec(x)**2
    >>> TR22(1 + cot(x)**2)
    csc(x)**2
    """
    def f(rv):
        if (not (isinstance(rv, Pow) and (rv.base.func in (cot, tan)))):
            return rv
        rv = _TR56(rv, tan, sec, (lambda x: (x - 1)), max=max, pow=pow)
        rv = _TR56(rv, cot, csc, (lambda x: (x - 1)), max=max, pow=pow)
        return rv
    return bottom_up(rv, f)