n, m = map(int, raw_input().strip().split())

bulbs = []
for i in xrange(m):
    line = map(int, raw_input().strip().split())
    bulbs.append(line[1:])

p = map(int, raw_input().strip().split())

ans = 0
for i in xrange(1 << n):
    lit = 0
    for j in xrange(m):
        l = bulbs[j]
        on = 0
        for switch in l:
            switch -= 1
            if (i & (1 << switch)): on += 1
        if (on - p[j]) % 2 == 0:
            lit += 1
    if lit == m:
        ans += 1

print ans