

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

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

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



#n,m = 2,3

#a = [[2,1,2], [1,1],[1,2]]

#target = [0,0,1]



ans = 0

s = [0] * n

for i in range(2**n):

  x = format(i,'b').zfill(n)



  for num,j in enumerate(x):

    s[num] = int(j)



  ck = 1

  for num,alist in enumerate(a):

    count = 0

    for j in range(1,alist[0]+1):

      count += s[alist[j]-1]

    if(count%2 != target[num]):

      ck = 0

  ans += ck



print(ans)
# n個のスイッチ

# m個の電球



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

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

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



#n,m = 2,2

#a = [[2,1,2],[1,2]]

#p = [0,1]



#n,m = 10,10

#a = [[4, 6, 3, 7, 5], [3, 1, 10, 5], [4, 8, 7, 1, 2], [5, 5, 10, 2, 7, 8], [6, 3, 1, 6, 8, 2, 5], [5, 6, 10, 7, 1, 3], [4, 3, 5, 7, 6], [4, 3, 9, 7, 5], [4, 3, 6, 5, 7], [4, 2, 7, 1, 8]]

#p = [0, 0, 1, 1, 1, 0, 0, 0, 0, 1]



ans = 0

for i in range(0,2**n): #スイッチの組み合わせを生成

  ck = True

  for j in range(0,m): #j番目の電球が付くかを確認

    # a[j][0]つながっているスイッチの数

    count = 0



    for k in range(0,a[j][0]):

      #print(a[j][k+1]) 番目のスイッチをチェック

      count += i>>(a[j][k+1]-1) & 1



    if count%2 != p[j]:

      ck = False

      break

  if ck:

    ans += 1

print(ans)

n, m = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(m)]
target = list(map(int, input().split()))
# n,m = 2,3
# a = [[2,1,2], [1,1],[1,2]]
# target = [0,0,1]
ans = 0
s = [0] * n
for i in range(2**n):
    x = format(i, "b").zfill(n)
    for num, j in enumerate(x):
        s[num] = int(j)
    ck = 1
    for num, alist in enumerate(a):
        count = 0
        for j in range(1, alist[0] + 1):
            count += s[alist[j] - 1]
        if count % 2 != target[num]:
            ck = 0
    ans += ck
print(ans)

# n個のスイッチ
# m個の電球
n, m = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
# n,m = 2,2
# a = [[2,1,2],[1,2]]
# p = [0,1]
# n,m = 10,10
# a = [[4, 6, 3, 7, 5], [3, 1, 10, 5], [4, 8, 7, 1, 2], [5, 5, 10, 2, 7, 8], [6, 3, 1, 6, 8, 2, 5], [5, 6, 10, 7, 1, 3], [4, 3, 5, 7, 6], [4, 3, 9, 7, 5], [4, 3, 6, 5, 7], [4, 2, 7, 1, 8]]
# p = [0, 0, 1, 1, 1, 0, 0, 0, 0, 1]
ans = 0
for i in range(0, 2**n):  # スイッチの組み合わせを生成
    ck = True
    for j in range(0, m):  # j番目の電球が付くかを確認
        # a[j][0]つながっているスイッチの数
        count = 0
        for k in range(0, a[j][0]):
            # print(a[j][k+1]) 番目のスイッチをチェック
            count += i >> (a[j][k + 1] - 1) & 1
        if count % 2 != p[j]:
            ck = False
            break
    if ck:
        ans += 1
print(ans)

+# n個のスイッチ +# m個の電球 -a = [list(map(int, input().split())) for i in range(m)] -target = list(map(int, input().split())) -# n,m = 2,3 -# a = [[2,1,2], [1,1],[1,2]] -# target = [0,0,1] +a = [list(map(int, input().split())) for _ in range(m)] +p = list(map(int, input().split())) +# n,m = 2,2 +# a = [[2,1,2],[1,2]] +# p = [0,1] +# n,m = 10,10 +# a = [[4, 6, 3, 7, 5], [3, 1, 10, 5], [4, 8, 7, 1, 2], [5, 5, 10, 2, 7, 8], [6, 3, 1, 6, 8, 2, 5], [5, 6, 10, 7, 1, 3], [4, 3, 5, 7, 6], [4, 3, 9, 7, 5], [4, 3, 6, 5, 7], [4, 2, 7, 1, 8]] +# p = [0, 0, 1, 1, 1, 0, 0, 0, 0, 1] -s = [0] * n -for i in range(2**n): -    x = format(i, "b").zfill(n) -    for num, j in enumerate(x): -        s[num] = int(j) -    ck = 1 -    for num, alist in enumerate(a): +for i in range(0, 2**n):  # スイッチの組み合わせを生成 +    ck = True +    for j in range(0, m):  # j番目の電球が付くかを確認 +        # a[j][0]つながっているスイッチの数 -        for j in range(1, alist[0] + 1): -            count += s[alist[j] - 1] -        if count % 2 != target[num]: -            ck = 0 -    ans += ck +        for k in range(0, a[j][0]): +            # print(a[j][k+1]) 番目のスイッチをチェック +            count += i >> (a[j][k + 1] - 1) & 1 +        if count % 2 != p[j]: +            ck = False +            break +    if ck: +        ans += 1