import sys
import math
import itertools


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, M = map(int, input().split())
    K = [[] for _ in range(M)]

    for j in range(M):
        k = list(map(int, input().split()))
        K[j] = set(k[1:])
    P = list(map(int, input().split()))
    count = 0
    l = list(range(1, N + 1))
    for i in range(0, N + 1):
        for comb in itertools.combinations(l, i):
            flag =0
            for j in range(M):  # denkyu
                temp = set(comb)
                if len(temp.intersection(K[j]) )% 2 != P[j]:
                    flag = 1
                    break
            if flag ==0:
                count +=1
    print(count)

if __name__ == "__main__":
    main() import sys sys import math math import itertools itertools def input():
    return sys.stdin.readline().rstrip() input return sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def main():
    N, M = map(int, input().split())
    K = [[] for _ in range(M)]

    for j in range(M):
        k = list(map(int, input().split()))
        K[j] = set(k[1:])
    P = list(map(int, input().split()))
    count = 0
    l = list(range(1, N + 1))
    for i in range(0, N + 1):
        for comb in itertools.combinations(l, i):
            flag =0
            for j in range(M):  # denkyu
                temp = set(comb)
                if len(temp.intersection(K[j]) )% 2 != P[j]:
                    flag = 1
                    break
            if flag ==0:
                count +=1
    print(count) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M [] for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [] K = [[] for _ in range(M)] K [[] for _ in range(M)] for j in range(M):
        k = list(map(int, input().split()))
        K[j] = set(k[1:])
     j range(M) range M k = list(map(int, input().split())) k list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split K[j] = set(k[1:]) K[j] K j set(k[1:]) set k[1:] k 1: 1 P = list(map(int, input().split())) P list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split count = 0 count 0 l = list(range(1, N + 1)) l list(range(1, N + 1)) list range(1, N + 1) range 1 N + 1 N 1 for i in range(0, N + 1):
        for comb in itertools.combinations(l, i):
            flag =0
            for j in range(M):  # denkyu
                temp = set(comb)
                if len(temp.intersection(K[j]) )% 2 != P[j]:
                    flag = 1
                    break
            if flag ==0:
                count +=1
     i range(0, N + 1) range 0 N + 1 N 1 for comb in itertools.combinations(l, i):
            flag =0
            for j in range(M):  # denkyu
                temp = set(comb)
                if len(temp.intersection(K[j]) )% 2 != P[j]:
                    flag = 1
                    break
            if flag ==0:
                count +=1
     comb itertools.combinations(l, i) itertools.combinations itertools combinations l i flag =0 flag 0 for j in range(M):  # denkyu
                temp = set(comb)
                if len(temp.intersection(K[j]) )% 2 != P[j]:
                    flag = 1
                    break
             j range(M) range M temp = set(comb) temp set(comb) set comb if len(temp.intersection(K[j]) )% 2 != P[j]:
                    flag = 1
                    break
             len(temp.intersection(K[j]) )% 2 != P[j] len(temp.intersection(K[j]) )% 2 len(temp.intersection(K[j]) ) len temp.intersection(K[j]) temp.intersection temp intersection K[j] K j 2 P[j] P j flag = 1 flag 1 break if flag ==0:
                count +=1
     flag ==0 flag 0 count +=1 count 1 print(count) print count if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N, M = map(int, input().split())
    K = [[] for _ in range(M)]

    for j in range(M):
        k = list(map(int, input().split()))
        K[j] = set(k[1:])
    P = list(map(int, input().split()))
    count = 0
    l = list(range(1, N + 1))
    for i in range(0, N + 1):
        for comb in itertools.combinations(l, i):
            flag =0
            for j in range(M):  # denkyu
                temp = set(comb)
                if len(temp.intersection(K[j]) )% 2 != P[j]:
                    flag = 1
                    break
            if flag ==0:
                count +=1
    print(count) def main():
    N, M = map(int, input().split())
    K = [[] for _ in range(M)]

    for j in range(M):
        k = list(map(int, input().split()))
        K[j] = set(k[1:])
    P = list(map(int, input().split()))
    count = 0
    l = list(range(1, N + 1))
    for i in range(0, N + 1):
        for comb in itertools.combinations(l, i):
            flag =0
            for j in range(M):  # denkyu
                temp = set(comb)
                if len(temp.intersection(K[j]) )% 2 != P[j]:
                    flag = 1
                    break
            if flag ==0:
                count +=1
    print(count) main def input():
    return sys.stdin.readline().rstrip() def input():
    return sys.stdin.readline().rstrip() input
import sys
import math
import itertools


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, M = map(int, input().split())
    K = [[] for _ in range(M)]

    for j in range(M):
        k = list(map(int, input().split()))
        K[j] = set(k[1:])
    P = list(map(int, input().split()))
    count = 0
    l = list(range(1, N + 1))
    for i in range(0, N + 1):
        for comb in itertools.combinations(l, i):
            flag =0
            for j in range(M):  # denkyu
                temp = set(comb)
                if len(temp.intersection(K[j]) )% 2 != P[j]:
                    flag = 1
                    break
            if flag ==0:
                count +=1
    print(count)

if __name__ == "__main__":
    main()
