n, m = [int(i) for i in input().split()]

ks = [[int(i) for i in input().split()] for _ in range(m)]

p = [int(i) for i in input().split()]

cnt = 0

for i in range(2**n):

  on = set(j + 1 for j in range(n) if i >> j & 1 == 1)

  flag = True

  for j in range(m):

    _, *s = ks[j]

    flag &= len(on & set(s)) % 2 == p[j]

  cnt += flag

print(cnt)

from itertools import product



n, m = list(map(int, input().split()))

l = [[int(i) for i in input().split()] for _ in range(m)]

p = [int(i) for i in input().split()]

c = 0

for sw in product((0, 1), repeat=n):

    for i in range(m):

        if sum(sw[si - 1] for si in l[i][1:]) % 2 != p[i]:

            break

    else:

        c += 1

print(c)

n, m = [int(i) for i in input().split()]
ks = [[int(i) for i in input().split()] for _ in range(m)]
p = [int(i) for i in input().split()]
cnt = 0
for i in range(2**n):
    on = set(j + 1 for j in range(n) if i >> j & 1 == 1)
    flag = True
    for j in range(m):
        _, *s = ks[j]
        flag &= len(on & set(s)) % 2 == p[j]
    cnt += flag
print(cnt)

from itertools import product

n, m = list(map(int, input().split()))
l = [[int(i) for i in input().split()] for _ in range(m)]
p = [int(i) for i in input().split()]
c = 0
for sw in product((0, 1), repeat=n):
    for i in range(m):
        if sum(sw[si - 1] for si in l[i][1:]) % 2 != p[i]:
            break
    else:
        c += 1
print(c)

-n, m = [int(i) for i in input().split()] -ks = [[int(i) for i in input().split()] for _ in range(m)] +from itertools import product + +n, m = list(map(int, input().split())) +l = [[int(i) for i in input().split()] for _ in range(m)] -cnt = 0 -for i in range(2**n): -    on = set(j + 1 for j in range(n) if i >> j & 1 == 1) -    flag = True -    for j in range(m): -        _, *s = ks[j] -        flag &= len(on & set(s)) % 2 == p[j] -    cnt += flag -print(cnt) +c = 0 +for sw in product((0, 1), repeat=n): +    for i in range(m): +        if sum(sw[si - 1] for si in l[i][1:]) % 2 != p[i]: +            break +    else: +        c += 1 +print(c)