import sys

input=sys.stdin.readline



def main():

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

    K=[]

    for i in range(M):

        K.append(list(map(int, input().split())))

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



    ans = 0

    for i in range(2**N):

        s = "{:0" + str(N) +"b}"

        b = True

        for j in range(M):

            x = 0

            for k in K[j][1:]:

                x += int(2**(N-k))

            s = "{:b}".format(i&x)

            if s.count("1")%2 != P[j]:

                b = False

                break

        if b:

            ans += 1

    print(ans)



if __name__ == '__main__':

    main()

import sys

input=sys.stdin.readline



def main():

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



    K=[]

    for i in range(M):

        sw = list(map(int, input().split()))

        x = 0

        for j in sw[1:]:

            x += 2**(j-1)

        K.append(x)



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



    ans = 0

    for i in range(2**N):

        b = True

        for j in range(M):

            if "{:b}".format(i&K[j]).count("1") %2 != P[j]:

                b = False

                break

        if b:

            ans += 1

    print(ans)



if __name__ == '__main__':

    main()

import sys

input = sys.stdin.readline


def main():
    N, M = list(map(int, input().split()))
    K = []
    for i in range(M):
        K.append(list(map(int, input().split())))
    P = list(map(int, input().split()))
    ans = 0
    for i in range(2**N):
        s = "{:0" + str(N) + "b}"
        b = True
        for j in range(M):
            x = 0
            for k in K[j][1:]:
                x += int(2 ** (N - k))
            s = "{:b}".format(i & x)
            if s.count("1") % 2 != P[j]:
                b = False
                break
        if b:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    N, M = list(map(int, input().split()))
    K = []
    for i in range(M):
        sw = list(map(int, input().split()))
        x = 0
        for j in sw[1:]:
            x += 2 ** (j - 1)
        K.append(x)
    P = list(map(int, input().split()))
    ans = 0
    for i in range(2**N):
        b = True
        for j in range(M):
            if "{:b}".format(i & K[j]).count("1") % 2 != P[j]:
                b = False
                break
        if b:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-        K.append(list(map(int, input().split()))) +        sw = list(map(int, input().split())) +        x = 0 +        for j in sw[1:]: +            x += 2 ** (j - 1) +        K.append(x) -        s = "{:0" + str(N) + "b}" -            x = 0 -            for k in K[j][1:]: -                x += int(2 ** (N - k)) -            s = "{:b}".format(i & x) -            if s.count("1") % 2 != P[j]: +            if "{:b}".format(i & K[j]).count("1") % 2 != P[j]: