from sys import stdin

from itertools import combinations_with_replacement,product



n,m = [int(x) for x in stdin.readline().rstrip().split()]

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]

p = list(map(int,stdin.readline().rstrip().split()))



hai = [0,1]

hai = list(product(hai, repeat=n))



point = 0



for i in range(len(hai)):

    h = list(hai[i])

    kai = 0

    for j in range(m):

        gou = 0

        for k in range(1,len(li[j])):

            if h[li[j][k]-1] == 1:

                gou += 1

        if p[j] != gou%2:

            kai += 1

    if kai == 0:

        point += 1

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

li = [list(map(int,input().split()))[1:] for _ in range(m)]

p = list(map(int,input().split()))

ans = 0



for i in range(1 << n):

    switch = set()

    for j in range(n):

        if (i >> j)&1:

            switch.add(j+1)

    for k in range(m):

        point = 0

        for l in li[k]:

            if l in switch:

                point += 1

        if point%2 != p[k]:

            break

    else:

        ans += 1



print(ans)
from sys import stdin
from itertools import combinations_with_replacement, product

n, m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(m)]
p = list(map(int, stdin.readline().rstrip().split()))
hai = [0, 1]
hai = list(product(hai, repeat=n))
point = 0
for i in range(len(hai)):
    h = list(hai[i])
    kai = 0
    for j in range(m):
        gou = 0
        for k in range(1, len(li[j])):
            if h[li[j][k] - 1] == 1:
                gou += 1
        if p[j] != gou % 2:
            kai += 1
    if kai == 0:
        point += 1
print(point)

n, m = list(map(int, input().split()))
li = [list(map(int, input().split()))[1:] for _ in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(1 << n):
    switch = set()
    for j in range(n):
        if (i >> j) & 1:
            switch.add(j + 1)
    for k in range(m):
        point = 0
        for l in li[k]:
            if l in switch:
                point += 1
        if point % 2 != p[k]:
            break
    else:
        ans += 1
print(ans)

-from sys import stdin -from itertools import combinations_with_replacement, product - -n, m = [int(x) for x in stdin.readline().rstrip().split()] -li = [list(map(int, stdin.readline().rstrip().split())) for _ in range(m)] -p = list(map(int, stdin.readline().rstrip().split())) -hai = [0, 1] -hai = list(product(hai, repeat=n)) -point = 0 -for i in range(len(hai)): -    h = list(hai[i]) -    kai = 0 -    for j in range(m): -        gou = 0 -        for k in range(1, len(li[j])): -            if h[li[j][k] - 1] == 1: -                gou += 1 -        if p[j] != gou % 2: -            kai += 1 -    if kai == 0: -        point += 1 -print(point) +n, m = list(map(int, input().split())) +li = [list(map(int, input().split()))[1:] for _ in range(m)] +p = list(map(int, input().split())) +ans = 0 +for i in range(1 << n): +    switch = set() +    for j in range(n): +        if (i >> j) & 1: +            switch.add(j + 1) +    for k in range(m): +        point = 0 +        for l in li[k]: +            if l in switch: +                point += 1 +        if point % 2 != p[k]: +            break +    else: +        ans += 1 +print(ans)