def slove():
    import sys
    import itertools
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    s = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    p = list(map(int, input().rstrip('\n').split()))
    ls = [True, False]
    a_cnt = 0
    for it in itertools.product(ls, repeat=n):
        cnt = 0
        b = True
        for i, v in enumerate(s):
            for j, vv in enumerate(v):
                if j != 0:
                    if it[vv-1]:
                        cnt += 1
            if p[i] != cnt % 2:
                b = False
                break
        if b:
            a_cnt += 1
    print(a_cnt)



if __name__ == '__main__':
    slove()
