import sys



readline = sys.stdin.readline



def main():

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



    S = []

    for i in range(M):

        k, *tmp = [int(i) for i in readline().split()]

        S.append(tmp)

    

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



    # bit

    ans = 0

    for i in range(2**N):

        select = []

        for j in range(N):

            if (i>>j) & 1:

                select.append(j+1)

        

        for m in range(M):

            flag = 1

            if sum([1 for x in S[m] if x in select])%2 != p[m]:

                flag = 0

                break

        if flag  == 1:

            ans += 1

        

    print(ans)





if __name__ == "__main__":

    main()

import sys



readline = sys.stdin.readline



def main():

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

    s = []

    for _ in range(M):

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

        s.append(set(stmp))

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



    ans = 0

    for i in range(2**N):

        flag = True

        onset = []

        for j in range(N):

            if (i>>j) & 1:

                onset.append(j+1)

        onset = set(onset)

        for m in range(M):

            union = onset & s[m]

            if len(union) % 2 != p[m]:

                flag = False

                break



        if flag:

            ans += 1



    print(ans)





if __name__ == "__main__":

    main()

import sys

readline = sys.stdin.readline


def main():
    N, M = list(map(int, readline().split()))
    S = []
    for i in range(M):
        k, *tmp = [int(i) for i in readline().split()]
        S.append(tmp)
    p = list(map(int, readline().split()))
    # bit
    ans = 0
    for i in range(2**N):
        select = []
        for j in range(N):
            if (i >> j) & 1:
                select.append(j + 1)
        for m in range(M):
            flag = 1
            if sum([1 for x in S[m] if x in select]) % 2 != p[m]:
                flag = 0
                break
        if flag == 1:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

import sys

readline = sys.stdin.readline


def main():
    N, M = list(map(int, readline().split()))
    s = []
    for _ in range(M):
        k, *stmp = list(map(int, readline().split()))
        s.append(set(stmp))
    p = list(map(int, readline().split()))
    ans = 0
    for i in range(2**N):
        flag = True
        onset = []
        for j in range(N):
            if (i >> j) & 1:
                onset.append(j + 1)
        onset = set(onset)
        for m in range(M):
            union = onset & s[m]
            if len(union) % 2 != p[m]:
                flag = False
                break
        if flag:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-    S = [] -    for i in range(M): -        k, *tmp = [int(i) for i in readline().split()] -        S.append(tmp) +    s = [] +    for _ in range(M): +        k, *stmp = list(map(int, readline().split())) +        s.append(set(stmp)) -    # bit -        select = [] +        flag = True +        onset = [] -                select.append(j + 1) +                onset.append(j + 1) +        onset = set(onset) -            flag = 1 -            if sum([1 for x in S[m] if x in select]) % 2 != p[m]: -                flag = 0 +            union = onset & s[m] +            if len(union) % 2 != p[m]: +                flag = False -        if flag == 1: +        if flag: