N,M = map(int,input().split())
lis = []
count = 0
temp = 0
flag = True
for _ in range(M):
  In = list(map(int,input().split()))
  lis.append(In)
p = list(map(int,input().split()))
for i in range(2**N):
  flag = True
  for j in range(M):
    temp = 0
    for k in range(1,lis[j][0]):
      temp += (i>>lis[j][k])
      if temp%2 != p[j]:
        flag = False
  if flag:
    count += 1
print(count)