n, m = map(int, input().split())
S = [list(map(int, input().split()))[1:] for _ in range(m)]
P = list(map(int, input().split()))
  
ans = 0
for b in range(2 ** n):
  onswitch = [i + 1 for i in range(n) if (b >> i) & 1]
  if all(sum(o in s for o in onswitch) % 2 == p for s, p in zip(S, P)):
    ans += 1
    
print(ans)