def powers(ring, p):
    """
    For every monomial m = X1^a1 * ... * Xn^an we can calculate
    tuple (a1,...,an) containing powers of variables.
    This function calculates the tuple whose coordinates 
    are sums of corresponding coordinates in powers tuples defined
    for monomials in polynomial p
    :param ring: polynomial ring of polynomial p
    :param p: input polynomial
    :return: tuple with sums of variables powers
    """
    _powers = tuple([0] * len(ring.gens()))
    for m in p.monomials():
        _powers = tuple(a + b for a, b in zip(_powers, m.degrees()))
    return _powers