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

k=[0]*m

s=[0]*m

for i in range(m):

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

  k[i] = tmp[0]

  s[i] = tmp[1:]

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



res=0

for bit in range(2**n):

  for i in range(m):

    cnt=0

    for sw in s[i]:

      if (bit >> (sw-1) & 1):

        cnt += 1

    if cnt % 2 != p[i]:

      break

  else:

    res+=1

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

k=[0]*m

s=[[0 for j in range(n)] for i in range(m)]

for i in range(m):

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

  k = x[0]

  for j in range(1, k+1):

    s[i][x[j]-1] = 1

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



ans = 0

for x in range(2**n):

  for i in range(m):

    cnt = 0

    for j in range(n):

      if (x >> j & 1) and s[i][j]:

        cnt += 1

    if cnt % 2 != p[i]:

      break

  else:  # breakしなかった=すべて一致した場合のみ

    ans += 1

print(ans)
n, m = list(map(int, input().split()))
k = [0] * m
s = [0] * m
for i in range(m):
    tmp = list(map(int, input().split()))
    k[i] = tmp[0]
    s[i] = tmp[1:]
p = list(map(int, input().split()))
res = 0
for bit in range(2**n):
    for i in range(m):
        cnt = 0
        for sw in s[i]:
            if bit >> (sw - 1) & 1:
                cnt += 1
        if cnt % 2 != p[i]:
            break
    else:
        res += 1
print(res)

n, m = list(map(int, input().split()))
k = [0] * m
s = [[0 for j in range(n)] for i in range(m)]
for i in range(m):
    x = list(map(int, input().split()))
    k = x[0]
    for j in range(1, k + 1):
        s[i][x[j] - 1] = 1
p = list(map(int, input().split()))
ans = 0
for x in range(2**n):
    for i in range(m):
        cnt = 0
        for j in range(n):
            if (x >> j & 1) and s[i][j]:
                cnt += 1
        if cnt % 2 != p[i]:
            break
    else:  # breakしなかった=すべて一致した場合のみ
        ans += 1
print(ans)

-s = [0] * m +s = [[0 for j in range(n)] for i in range(m)] -    tmp = list(map(int, input().split())) -    k[i] = tmp[0] -    s[i] = tmp[1:] +    x = list(map(int, input().split())) +    k = x[0] +    for j in range(1, k + 1): +        s[i][x[j] - 1] = 1 -res = 0 -for bit in range(2**n): +ans = 0 +for x in range(2**n): -        for sw in s[i]: -            if bit >> (sw - 1) & 1: +        for j in range(n): +            if (x >> j & 1) and s[i][j]: -    else: -        res += 1 -print(res) +    else:  # breakしなかった=すべて一致した場合のみ +        ans += 1 +print(ans)