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

ans = 0;
for i in range(2**n):
  flag = True
  for j in range(m):
    c = 0
    for k in km[j][1:]:
      if i & 2**(k-1):
        c += 1
    if (c%2 != p[j]):
      flag = False
  if flag:
    ans += 1
print(ans)