import sys
from functools import reduce
def c():
    p = [[int(t) for t in r.split(' ')] for r in sys.stdin.read().split('\n') if r != '']
    N, M = p[0]
    l = p[1:M + 1]
    cond = p[M + 1]
    count = 0
    for i in range(0, 1<<N):
        cc = 0
        for j in range(0, M):
            b = 0b0
            for k in l[j]:
                if (i >> (k - 1)) & 0b1 == 1:
                    b = ~b
            if b & 0b1 != cond[j]:
                break
            cc = cc + 1
        if cc == M:
            count = count + 1
    print(count)
c()
