def amcheck(lst_p, pattern, subset=True):
    """
    Anti-monotonicity check. Checks if a GP is a subset or superset of an already existing GP

    :param lst_p: list of existing GPs
    :param pattern: GP to be checked
    :param subset: check if it is a subset
    :return: True if superset/subset, False otherwise
    """
    result = False
    if subset:
        for pat in lst_p:
            result1 = set(pattern.get_pattern()).issubset(set(pat.get_pattern()))
            result2 = set(pattern.inv_pattern()).issubset(set(pat.get_pattern()))
            if result1 or result2:
                result = True
                break
    else:
        for pat in lst_p:
            result1 = set(pattern.get_pattern()).issuperset(set(pat.get_pattern()))
            result2 = set(pattern.inv_pattern()).issuperset(set(pat.get_pattern()))
            if result1 or result2:
                result = True
                break
    return result