#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 12, 2020 17:07:34 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


def main():
  N, M = list(map(int, input().split()))
  l_s = []
  for i in range(M):
    l_s.append(list(map(int, input().split()))[1:])
  P = list(map(int, input().split()))

  ans = 0
  for bit in range(1 << N):
    # loop for light
    for lidx, ss in enumerate(l_s):

      num_on_s = 0
      for s in ss:
        mask = (1 << (s-1))
        if bit & mask:
          num_on_s += 1
      if num_on_s % 2 == P[lidx]:
        continue
      break
    else:
      ans += 1
  print(ans)


if(__name__ == '__main__'):
  main() __giturl__ = "$URL$" __giturl__ "$URL$" from sys import stdin input = stdin.readline input stdin.readline stdin readline def main():
  N, M = list(map(int, input().split()))
  l_s = []
  for i in range(M):
    l_s.append(list(map(int, input().split()))[1:])
  P = list(map(int, input().split()))

  ans = 0
  for bit in range(1 << N):
    # loop for light
    for lidx, ss in enumerate(l_s):

      num_on_s = 0
      for s in ss:
        mask = (1 << (s-1))
        if bit & mask:
          num_on_s += 1
      if num_on_s % 2 == P[lidx]:
        continue
      break
    else:
      ans += 1
  print(ans) main N, M = list(map(int, input().split())) N list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split M l_s = [] l_s [] for i in range(M):
    l_s.append(list(map(int, input().split()))[1:])
   i range(M) range M l_s.append(list(map(int, input().split()))[1:]) l_s.append l_s append list(map(int, input().split()))[1:] (map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 1: 1 P = list(map(int, input().split())) P list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for bit in range(1 << N):
    # loop for light
    for lidx, ss in enumerate(l_s):

      num_on_s = 0
      for s in ss:
        mask = (1 << (s-1))
        if bit & mask:
          num_on_s += 1
      if num_on_s % 2 == P[lidx]:
        continue
      break
    else:
      ans += 1
   bit range(1 << N) range 1 << N 1 N for lidx, ss in enumerate(l_s):

      num_on_s = 0
      for s in ss:
        mask = (1 << (s-1))
        if bit & mask:
          num_on_s += 1
      if num_on_s % 2 == P[lidx]:
        continue
      break
    else:
      ans += 1
   lidx ss enumerate(l_s) enumerate l_s num_on_s = 0 num_on_s 0 for s in ss:
        mask = (1 << (s-1))
        if bit & mask:
          num_on_s += 1
       s ss mask = (1 << (s-1)) mask 1 << (s-1) 1 s-1 s 1 if bit & mask:
          num_on_s += 1
       bit & mask bit mask num_on_s += 1 num_on_s 1 if num_on_s % 2 == P[lidx]:
        continue
       num_on_s % 2 == P[lidx] num_on_s % 2 num_on_s 2 P[lidx] P lidx continue break ans += 1 ans 1 print(ans) print ans if(__name__ == '__main__'):
  main() __name__ == '__main__' __name__ '__main__' main() main input = stdin.readline stdin.readline input def main():
  N, M = list(map(int, input().split()))
  l_s = []
  for i in range(M):
    l_s.append(list(map(int, input().split()))[1:])
  P = list(map(int, input().split()))

  ans = 0
  for bit in range(1 << N):
    # loop for light
    for lidx, ss in enumerate(l_s):

      num_on_s = 0
      for s in ss:
        mask = (1 << (s-1))
        if bit & mask:
          num_on_s += 1
      if num_on_s % 2 == P[lidx]:
        continue
      break
    else:
      ans += 1
  print(ans) def main():
  N, M = list(map(int, input().split()))
  l_s = []
  for i in range(M):
    l_s.append(list(map(int, input().split()))[1:])
  P = list(map(int, input().split()))

  ans = 0
  for bit in range(1 << N):
    # loop for light
    for lidx, ss in enumerate(l_s):

      num_on_s = 0
      for s in ss:
        mask = (1 << (s-1))
        if bit & mask:
          num_on_s += 1
      if num_on_s % 2 == P[lidx]:
        continue
      break
    else:
      ans += 1
  print(ans) main
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 12, 2020 17:07:34 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


def main():
  N, M = list(map(int, input().split()))
  l_s = []
  for i in range(M):
    l_s.append(list(map(int, input().split()))[1:])
  P = list(map(int, input().split()))

  ans = 0
  for bit in range(1 << N):
    # loop for light
    for lidx, ss in enumerate(l_s):

      num_on_s = 0
      for s in ss:
        mask = (1 << (s-1))
        if bit & mask:
          num_on_s += 1
      if num_on_s % 2 == P[lidx]:
        continue
      break
    else:
      ans += 1
  print(ans)


if(__name__ == '__main__'):
  main()
