n, m = map(int, input().split())
ss = [set(list(map(int, input().split()))[1:]) for _ in range(m)]
ps = list(map(int, input().split()))

ans = 0
for bits in range(2 ** n):
    ons = set()
    b = bits
    for shift in range(10):
        b = b >> shift
        if b & 1 > 0:
            ons.add(shift + 1)

    ok = True
    for i in range(m):
        c = [s in ons for s in ss[i]].count(True)
        if c % 2 != ps[i]:
            ok = False
            break
    if ok:
        ans += 1

print(ans)
