def polymulmodp(a, b, p):
    """
    Multiplies the polynomials a and b and reduces their coefficients mod p.
    Polynomials are written as lists of integers with the constant terms first.
    If the high-degree coefficients are zero, those terms will be deleted from
    the answer so that the highest-degree term is nonzero.  We assume that the
    inputs also satisfy this property.  The zero polynomial is represented by
    the empty list.  If one of the input polynomials is None, we return None.
    Input:
        a, b -- polynomials
        p -- integer
    Output: A polynomial.
    Examples:
    >>> polymulmodp([1,2,3], [4,5,6], 7)
    [4, 6, 0, 6, 4]
    >>> polymulmodp([2,2], [3,3,3], 6)
    []
    """
    if a is None or b is None:
        return None
    c = [0] * (len(a) + len(b) - 1)
    for k, x in enumerate(a):
        for l, y in enumerate(b):
            c[k + l] += x * y
    for k, x in enumerate(c):
        c[k] = x % p
    while len(c) > 0 and c[-1] == 0:
        del c[-1]
    return c
