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



info=[list(map(int,input().split())) for i in range(m)]



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



ans=0

for i in range(2**n):

  tmp=0

  f=1

  for mm in range(m):

    tmp=0

    for j in info[mm][1:]:

      tmp+=int(str(format(i,'b').zfill(n))[int(j)-1])

    if tmp%2!=p[mm]:

      f=0

  if f==1:

    ans+=1

print(ans)

import sys

input = sys.stdin.readline

input = sys.stdin.buffer.readline





def II(): return int(eval(input()))

def MI(): return list(map(int,input().split()))

def LI(): return list(map(int,input().split()))

def TI(): return tuple(map(int,input().split()))



# mod=10**9+7

# rstrip().decode('utf-8')





def main():

	n,m=MI()

	ks=[LI() for _ in range(m)]

	s=[i[1:] for i in ks]

	p=LI()

	ans=0



	for i in range(1<<n):

		li=[0]*m

		for j in range(n):

			for k in range(m):

				if 1&i>>j:

					if j+1 in s[k]:

						li[k]=1-li[k]

		if p==li:

			ans+=1

	print(ans)





















if __name__ == "__main__":

	main()

n, m = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    tmp = 0
    f = 1
    for mm in range(m):
        tmp = 0
        for j in info[mm][1:]:
            tmp += int(str(format(i, "b").zfill(n))[int(j) - 1])
        if tmp % 2 != p[mm]:
            f = 0
    if f == 1:
        ans += 1
print(ans)

import sys

input = sys.stdin.readline
input = sys.stdin.buffer.readline


def II():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def TI():
    return tuple(map(int, input().split()))


# mod=10**9+7
# rstrip().decode('utf-8')
def main():
    n, m = MI()
    ks = [LI() for _ in range(m)]
    s = [i[1:] for i in ks]
    p = LI()
    ans = 0
    for i in range(1 << n):
        li = [0] * m
        for j in range(n):
            for k in range(m):
                if 1 & i >> j:
                    if j + 1 in s[k]:
                        li[k] = 1 - li[k]
        if p == li:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-n, m = list(map(int, input().split())) -info = [list(map(int, input().split())) for i in range(m)] -p = list(map(int, input().split())) -ans = 0 -for i in range(2**n): -    tmp = 0 -    f = 1 -    for mm in range(m): -        tmp = 0 -        for j in info[mm][1:]: -            tmp += int(str(format(i, "b").zfill(n))[int(j) - 1]) -        if tmp % 2 != p[mm]: -            f = 0 -    if f == 1: -        ans += 1 -print(ans) +import sys + +input = sys.stdin.readline +input = sys.stdin.buffer.readline + + +def II(): +    return int(eval(input())) + + +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def TI(): +    return tuple(map(int, input().split())) + + +# mod=10**9+7 +# rstrip().decode('utf-8') +def main(): +    n, m = MI() +    ks = [LI() for _ in range(m)] +    s = [i[1:] for i in ks] +    p = LI() +    ans = 0 +    for i in range(1 << n): +        li = [0] * m +        for j in range(n): +            for k in range(m): +                if 1 & i >> j: +                    if j + 1 in s[k]: +                        li[k] = 1 - li[k] +        if p == li: +            ans += 1 +    print(ans) + + +if __name__ == "__main__": +    main()