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


if __name__ == '__main__':
    slove()
