def element(point, p, q, n):
    """Test, whether the given point is on the curve (p, q, n)"""
    if point:
        x, y = point
        return (x * x * x - p * x - q) % n == (y * y) % n
    else:
        return True