from itertools import product


def li():
    return list(map(int, input().split()))


def is_on(state, p, s_list):
    return sum(list(map(lambda x: state[x - 1], s_list))) % 2 == p


if __name__ == '__main__':
    [n, m] = li()
    ks_list = [li() for _ in range(m)]
    p_list = li()

    pattern = 0

    for state in product([0, 1], repeat=n):
        is_all = True
        for index, ks in enumerate(ks_list):
            if not is_on(state, p_list[index], ks[:1]):
                is_all = False
        if is_all:
            pattern = pattern + 1
    print(pattern)
