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

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

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

output = 0



for i in range(2 ** n):

  lights = []

  for j in range(n+1):

    if ((i >> j) & 1):

      lights.append(j+1)

      

  for inde, l in enumerate(l_list):

    if len(set(l[1:]) & set(lights)) % 2 != p[inde]:

      break

  else:

    output += 1

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

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

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

output = 0



for i in range(2 ** n):

  lights = []

  for j in range(n+1):

    if ((i >> j) & 1):

      lights.append(j+1)

      

  for k, l in enumerate(l_list):

    if len(set(l[1:]) & set(lights)) % 2 != p[k]:

      break

  else:

    output += 1

print(output)
n, m = list(map(int, input().split()))
l_list = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
output = 0
for i in range(2**n):
    lights = []
    for j in range(n + 1):
        if (i >> j) & 1:
            lights.append(j + 1)
    for inde, l in enumerate(l_list):
        if len(set(l[1:]) & set(lights)) % 2 != p[inde]:
            break
    else:
        output += 1
print(output)

n, m = list(map(int, input().split()))
l_list = [list(map(int, input().split())) for i in range(m)]
p = list(map(int, input().split()))
output = 0
for i in range(2**n):
    lights = []
    for j in range(n + 1):
        if (i >> j) & 1:
            lights.append(j + 1)
    for k, l in enumerate(l_list):
        if len(set(l[1:]) & set(lights)) % 2 != p[k]:
            break
    else:
        output += 1
print(output)

-    for inde, l in enumerate(l_list): -        if len(set(l[1:]) & set(lights)) % 2 != p[inde]: +    for k, l in enumerate(l_list): +        if len(set(l[1:]) & set(lights)) % 2 != p[k]: