def slove():

    import sys

    import bisect

    import collections

    import fractions

    import heapq

    import itertools

    input = sys.stdin.readline

    n, m = list(map(int, input().rstrip('\n').split()))

    ks = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]

    p = list(map(int, input().rstrip('\n').split()))

    a_cnt = 0

    for v in itertools.product([True, False], repeat=n):

        b = True

        for j, vv in enumerate(ks):

            cnt = 0

            for i in range(vv[0]):

                if v[vv[i+1]-1]:

                    cnt += 1

            if cnt % 2 != p[j]:

                b = False

                break

        if b:

            a_cnt += 1

    print(a_cnt)





if __name__ == '__main__':

    slove()

import sys

import itertools





def solve():

    input = sys.stdin.readline

    mod = 10 ** 9 + 7

    n, m = list(map(int, input().rstrip('\n').split()))

    ks = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]

    p = list(map(int, input().rstrip('\n').split()))

    cnt = 0

    for v in itertools.product([True, False], repeat=n):

        b = True

        for i in range(m):

            t = 0

            for kv in ks[i][1:]:

                t += v[kv-1]

            if t % 2 != p[i]:

                b = False

                break

        if b:

            cnt += 1

    print(cnt)





if __name__ == '__main__':

    solve()

def slove():
    import sys
    import bisect
    import collections
    import fractions
    import heapq
    import itertools

    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip("\n").split()))
    ks = [list(map(int, input().rstrip("\n").split())) for _ in range(m)]
    p = list(map(int, input().rstrip("\n").split()))
    a_cnt = 0
    for v in itertools.product([True, False], repeat=n):
        b = True
        for j, vv in enumerate(ks):
            cnt = 0
            for i in range(vv[0]):
                if v[vv[i + 1] - 1]:
                    cnt += 1
            if cnt % 2 != p[j]:
                b = False
                break
        if b:
            a_cnt += 1
    print(a_cnt)


if __name__ == "__main__":
    slove()

import sys
import itertools


def solve():
    input = sys.stdin.readline
    mod = 10**9 + 7
    n, m = list(map(int, input().rstrip("\n").split()))
    ks = [list(map(int, input().rstrip("\n").split())) for _ in range(m)]
    p = list(map(int, input().rstrip("\n").split()))
    cnt = 0
    for v in itertools.product([True, False], repeat=n):
        b = True
        for i in range(m):
            t = 0
            for kv in ks[i][1:]:
                t += v[kv - 1]
            if t % 2 != p[i]:
                b = False
                break
        if b:
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    solve()

-def slove(): -    import sys -    import bisect -    import collections -    import fractions -    import heapq -    import itertools +import sys +import itertools + +def solve(): +    mod = 10**9 + 7 -    a_cnt = 0 +    cnt = 0 -        for j, vv in enumerate(ks): -            cnt = 0 -            for i in range(vv[0]): -                if v[vv[i + 1] - 1]: -                    cnt += 1 -            if cnt % 2 != p[j]: +        for i in range(m): +            t = 0 +            for kv in ks[i][1:]: +                t += v[kv - 1] +            if t % 2 != p[i]: -            a_cnt += 1 -    print(a_cnt) +            cnt += 1 +    print(cnt) -    slove() +    solve()