'Remove GCD of terms from the polynomial ``f``.
Examples
>>> from sympy import Poly
>>> from sympy.abc import x, y
>>> Poly(x**6*y**2 + x**3*y, x, y).terms_gcd()
((3, 1), Poly(x**3*y + 1, x, y, domain=\'ZZ\'))'

def terms_gcd(f):

    if hasattr(f.rep, 'terms_gcd'):
        (J, result) = f.rep.terms_gcd()
    else:
        raise OperationNotSupported(f, 'terms_gcd')
    return (J, f.per(result))
