from collections import deque

from collections import Counter

from itertools import product, permutations,combinations

from operator import itemgetter

from heapq import heappop, heappush

from bisect import bisect_left, bisect_right, bisect

#pypyではscipy, numpyは使えない

#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree

#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix

#import numpy as np

from fractions import gcd

from math import ceil,floor, sqrt, cos, sin, pi, factorial

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10**8)

INF = float('inf')

MOD = 10**9+7



def main():

  n, m = list(map(int, readline().split()))

  sw = [[] for _ in range(m)]

  for i in range(m):

    sw[i] = list(map(int, readline().split()[1:]))

  p = [int(x) for x in input().split()] # 不要

  answer = 0

  

  for jotai in product([0,1], repeat=n):

    bl = True

    for i in range(m):

      s = sum([jotai[s-1] for s in sw[i]])

      if (s-p[i])%2 != 0:

        bl = False

        break

    if bl:

      answer += 1

  print(answer)

  

  

  

if __name__ == '__main__':

  main()
import sys

read = sys.stdin.read

readline = sys.stdin.buffer.readline

from itertools import product

sys.setrecursionlimit(10 ** 8)

INF = float('inf')

MOD = 10 ** 9 + 7





def main():

    N, M = list(map(int, readline().split()))

    S = []

    for _ in range(M):

        k, *s = list(map(int, readline().split()))

        S.append(s)

    P = list(map(int, readline().split()))

    ans = 0



    for switch in product((0,1),repeat=N):

        for i, s in enumerate(S):

            tmp = 0

            for k in s:

                tmp ^= switch[k-1]

            if tmp==P[i]:

                continue

            else:

                break

        else:

            ans += 1



    print(ans)





if __name__ == '__main__':

    main()



from collections import deque
from collections import Counter
from itertools import product, permutations, combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect

# pypyではscipy, numpyは使えない
# from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
# from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
# import numpy as np
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi, factorial
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float("inf")
MOD = 10**9 + 7


def main():
    n, m = list(map(int, readline().split()))
    sw = [[] for _ in range(m)]
    for i in range(m):
        sw[i] = list(map(int, readline().split()[1:]))
    p = [int(x) for x in input().split()]  # 不要
    answer = 0
    for jotai in product([0, 1], repeat=n):
        bl = True
        for i in range(m):
            s = sum([jotai[s - 1] for s in sw[i]])
            if (s - p[i]) % 2 != 0:
                bl = False
                break
        if bl:
            answer += 1
    print(answer)


if __name__ == "__main__":
    main()

import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
from itertools import product

sys.setrecursionlimit(10**8)
INF = float("inf")
MOD = 10**9 + 7


def main():
    N, M = list(map(int, readline().split()))
    S = []
    for _ in range(M):
        k, *s = list(map(int, readline().split()))
        S.append(s)
    P = list(map(int, readline().split()))
    ans = 0
    for switch in product((0, 1), repeat=N):
        for i, s in enumerate(S):
            tmp = 0
            for k in s:
                tmp ^= switch[k - 1]
            if tmp == P[i]:
                continue
            else:
                break
        else:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-from collections import deque -from collections import Counter -from itertools import product, permutations, combinations -from operator import itemgetter -from heapq import heappop, heappush -from bisect import bisect_left, bisect_right, bisect - -# pypyではscipy, numpyは使えない -# from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree -# from scipy.sparse import csr_matrix, coo_matrix, lil_matrix -# import numpy as np -from fractions import gcd -from math import ceil, floor, sqrt, cos, sin, pi, factorial -read = sys.stdin.buffer.read +read = sys.stdin.read -readlines = sys.stdin.buffer.readlines +from itertools import product + -    n, m = list(map(int, readline().split())) -    sw = [[] for _ in range(m)] -    for i in range(m): -        sw[i] = list(map(int, readline().split()[1:])) -    p = [int(x) for x in input().split()]  # 不要 -    answer = 0 -    for jotai in product([0, 1], repeat=n): -        bl = True -        for i in range(m): -            s = sum([jotai[s - 1] for s in sw[i]]) -            if (s - p[i]) % 2 != 0: -                bl = False +    N, M = list(map(int, readline().split())) +    S = [] +    for _ in range(M): +        k, *s = list(map(int, readline().split())) +        S.append(s) +    P = list(map(int, readline().split())) +    ans = 0 +    for switch in product((0, 1), repeat=N): +        for i, s in enumerate(S): +            tmp = 0 +            for k in s: +                tmp ^= switch[k - 1] +            if tmp == P[i]: +                continue +            else: -        if bl: -            answer += 1 -    print(answer) +        else: +            ans += 1 +    print(ans)