N, M = map(int, input().split())
l = []
for _ in range(M):
  l.append(list(map(int, input().split())))
p = list(map(int, input().split()))

m = [0] * M # 電球のonoffチェック。on:1 off:0
cnt1 = 0 # 1の個数を数える
cnt2 = 0 # 答え

for i in range(2 ** N):
  for j in range(M):
    for k in range(l[j][0]):
      if (i >> (l[j][k+1] - 1) & 1):
        cnt1 += 1
    if cnt1 % 2 == p[j-1]:
      m[j-1] = 1
    cnt1 = 0
  if m == [1] * M:
    cnt2 += 1
  m = [0] * M
print(cnt2)