N,M = list(map(int,input().split()))

ls = []



for i in range(M):

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

  ls.append(s[1:])



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

#greedy O(2^N)(MN) : (all set of switch N) = 2^10 * M 10 10^4 OK

ans = 0

for i in range(2**N): # all set of N  2**N == 1 << N (shif operator N right shift)

  for j in range(M): # i_th lump consider

    cnt = 0 

    for k in ls[j]:

      if i&(1<<(k-1)): # if switch k is ON, then return non-zero(True)

        cnt += 1

    if cnt%2 != p[j]:

      break

  else:

    ans +=1

print(ans)

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

light = []

for i in range(m):

  light.append(list(map(int,input().split())))

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

# bit全探索 nで スイッチのパターンを全てためす

# 

ans = 0

for i in range(2**n):

  ng = 0

  for j in range(m):

    ans_j = 0

    for k in range(n):

      if i >> k & 1 and k+1 in light[j][1:]:#電球on かつk[i]の電球がついているなら+=1

        #print(light[j][1:],k)

        ans_j += 1

    #print(ans_j,i,p[j],ng)

    if ans_j % 2 != p[j]:

      ng = 1

  if ng == 0:

    ans += 1

print(ans)

N, M = list(map(int, input().split()))
ls = []
for i in range(M):
    s = list(map(int, input().split()))
    ls.append(s[1:])
p = list(map(int, input().split()))
# greedy O(2^N)(MN) : (all set of switch N) = 2^10 * M 10 10^4 OK
ans = 0
for i in range(2**N):  # all set of N  2**N == 1 << N (shif operator N right shift)
    for j in range(M):  # i_th lump consider
        cnt = 0
        for k in ls[j]:
            if i & (1 << (k - 1)):  # if switch k is ON, then return non-zero(True)
                cnt += 1
        if cnt % 2 != p[j]:
            break
    else:
        ans += 1
print(ans)

n, m = list(map(int, input().split()))
light = []
for i in range(m):
    light.append(list(map(int, input().split())))
p = list(map(int, input().split()))
# bit全探索 nで スイッチのパターンを全てためす
#
ans = 0
for i in range(2**n):
    ng = 0
    for j in range(m):
        ans_j = 0
        for k in range(n):
            if i >> k & 1 and k + 1 in light[j][1:]:  # 電球on かつk[i]の電球がついているなら+=1
                # print(light[j][1:],k)
                ans_j += 1
        # print(ans_j,i,p[j],ng)
        if ans_j % 2 != p[j]:
            ng = 1
    if ng == 0:
        ans += 1
print(ans)

-N, M = list(map(int, input().split())) -ls = [] -for i in range(M): -    s = list(map(int, input().split())) -    ls.append(s[1:]) +n, m = list(map(int, input().split())) +light = [] +for i in range(m): +    light.append(list(map(int, input().split()))) -# greedy O(2^N)(MN) : (all set of switch N) = 2^10 * M 10 10^4 OK +# bit全探索 nで スイッチのパターンを全てためす +# -for i in range(2**N):  # all set of N  2**N == 1 << N (shif operator N right shift) -    for j in range(M):  # i_th lump consider -        cnt = 0 -        for k in ls[j]: -            if i & (1 << (k - 1)):  # if switch k is ON, then return non-zero(True) -                cnt += 1 -        if cnt % 2 != p[j]: -            break -    else: +for i in range(2**n): +    ng = 0 +    for j in range(m): +        ans_j = 0 +        for k in range(n): +            if i >> k & 1 and k + 1 in light[j][1:]:  # 電球on かつk[i]の電球がついているなら+=1 +                # print(light[j][1:],k) +                ans_j += 1 +        # print(ans_j,i,p[j],ng) +        if ans_j % 2 != p[j]: +            ng = 1 +    if ng == 0: