n,m = map(int, input().split())
S = [list(map(int, input().split())) for i in range(m)]
P = list(map(int, input().split()))
c = 0
a = 0
for a in range(2**n):
  a2 = format(a, 'b').zfill(n)
  d = 0
  for i in range(m):
    o = 0
    for j in range(S[i][0]):
      o += int(a2[S[i][j+1]-1])
    if o % 2 == P[i]:
      d += 1
  if d == m:
    c += 1
print(c)