f = lambda : map(int, input().split())

n, m = f()
ll = [[0]*n for i in range(m)]
for i in range(m):
  k, *t = f()
  for j in range(k):
    ll[i][t[j]-1] = 1
lp = list(f())

import itertools as it
ans = 0

for p in it.product([0,1], repeat=n):
  if lp == [sum(a*b for a, b in zip(p,l))%2 for l in ll]:
    ans += 1

print(ans)