def main():

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

    S = []

    for i in range(M):

        S.append(list([int(x) - 1 for x in input().split()])[1:])

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



    ans = 0

    for bit in range(1 << N):

        for i in range(M):

            on = 0

            for j in S[i]:

                if bit & (1 << j):

                    on += 1

            if on % 2 != P[i]:

                break

        else:

            ans += 1

    print(ans)





if __name__ == '__main__':

    main()

def main():

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

    S = [list([int(x) - 1 for x in input().split()])[1:] for _ in range(M)]

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



    ans = 0

    for bit in range(1 << N):

        for i in range(M):

            on = 0

            for j in S[i]:

                if bit & (1 << j):

                    on += 1

            if on % 2 != P[i]:

                break

        else:

            ans += 1

    print(ans)





if __name__ == '__main__':

    main()

def main():
    N, M = list(map(int, input().split()))
    S = []
    for i in range(M):
        S.append(list([int(x) - 1 for x in input().split()])[1:])
    P = list(map(int, input().split()))
    ans = 0
    for bit in range(1 << N):
        for i in range(M):
            on = 0
            for j in S[i]:
                if bit & (1 << j):
                    on += 1
            if on % 2 != P[i]:
                break
        else:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

def main():
    N, M = list(map(int, input().split()))
    S = [list([int(x) - 1 for x in input().split()])[1:] for _ in range(M)]
    P = list(map(int, input().split()))
    ans = 0
    for bit in range(1 << N):
        for i in range(M):
            on = 0
            for j in S[i]:
                if bit & (1 << j):
                    on += 1
            if on % 2 != P[i]:
                break
        else:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-    S = [] -    for i in range(M): -        S.append(list([int(x) - 1 for x in input().split()])[1:]) +    S = [list([int(x) - 1 for x in input().split()])[1:] for _ in range(M)]