N,M=map(int,input().split())
ls3 = []
for i in range(M):
    ls1=list(map(int,input().split()))
    ls1.pop(0)
    ls3.append(ls1)
ls2 = list(map(int,input().split()))

kk = 0
for i in range(2**N):
    ls4 = [0]*M
    for j in range(N):
        if (i>>j&1):
            for k in range(M):
                if j+1 in ls3[k]:
                    ls4[k] += 1
    ii = 0
    for l in range(M):
        if ls4[l] % 2==ls2[l]:
            ii += 1

    if ii == M:
        kk += 1
print(kk) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M ls3 = [] ls3 [] for i in range(M):
    ls1=list(map(int,input().split()))
    ls1.pop(0)
    ls3.append(ls1) i range(M) range M ls1=list(map(int,input().split())) ls1 list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split ls1.pop(0) ls1.pop ls1 pop 0 ls3.append(ls1) ls3.append ls3 append ls1 ls2 = list(map(int,input().split())) ls2 list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split kk = 0 kk 0 for i in range(2**N):
    ls4 = [0]*M
    for j in range(N):
        if (i>>j&1):
            for k in range(M):
                if j+1 in ls3[k]:
                    ls4[k] += 1
    ii = 0
    for l in range(M):
        if ls4[l] % 2==ls2[l]:
            ii += 1

    if ii == M:
        kk += 1 i range(2**N) range 2**N 2 N ls4 = [0]*M ls4 [0]*M [0] 0 M for j in range(N):
        if (i>>j&1):
            for k in range(M):
                if j+1 in ls3[k]:
                    ls4[k] += 1
     j range(N) range N if (i>>j&1):
            for k in range(M):
                if j+1 in ls3[k]:
                    ls4[k] += 1
     i>>j&1 i>>j i j 1 for k in range(M):
                if j+1 in ls3[k]:
                    ls4[k] += 1
     k range(M) range M if j+1 in ls3[k]:
                    ls4[k] += 1
     j+1 in ls3[k] j+1 j 1 ls3[k] ls3 k ls4[k] += 1 ls4[k] ls4 k 1 ii = 0 ii 0 for l in range(M):
        if ls4[l] % 2==ls2[l]:
            ii += 1

     l range(M) range M if ls4[l] % 2==ls2[l]:
            ii += 1

     ls4[l] % 2==ls2[l] ls4[l] % 2 ls4[l] ls4 l 2 ls2[l] ls2 l ii += 1 ii 1 if ii == M:
        kk += 1 ii == M ii M kk += 1 kk 1 print(kk) print kk ii = 0 0 ii ii += 1 1 ii kk += 1 1 kk kk = 0 0 kk ls3 = [] [] ls3 ls1=list(map(int,input().split())) list(map(int,input().split())) ls1 N,M=map(int,input().split()) map(int,input().split()) N ls2 = list(map(int,input().split())) list(map(int,input().split())) ls2 M=map(int,input().split()) map(int,input().split()) M ls4 = [0]*M [0]*M ls4
N,M=map(int,input().split())
ls3 = []
for i in range(M):
    ls1=list(map(int,input().split()))
    ls1.pop(0)
    ls3.append(ls1)
ls2 = list(map(int,input().split()))

kk = 0
for i in range(2**N):
    ls4 = [0]*M
    for j in range(N):
        if (i>>j&1):
            for k in range(M):
                if j+1 in ls3[k]:
                    ls4[k] += 1
    ii = 0
    for l in range(M):
        if ls4[l] % 2==ls2[l]:
            ii += 1

    if ii == M:
        kk += 1
print(kk)