N,M = map(int,input().split())
Connect = [0] * M
for i in range(M):
    k, *Connect[i] = map(int,input().split())
P = list(map(int,input().split()))
Switch = [0] * N
ans = 0
for i in range(1<<N):
    for j in range(N):
        bit = i>>j & 1
        Switch[j] = bit
    flag = True
    for l in range(M):
        count = 0
        for c in Connect[l]:
            if Switch[c-1]:
                count+=1
        if not P[l] == count % 2:
            flag = False
    if flag:
        ans += 1

print(ans)




 N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M Connect = [0] * M Connect [0] * M [0] 0 M for i in range(M):
    k, *Connect[i] = map(int,input().split()) i range(M) range M k, *Connect[i] = map(int,input().split()) k map(int,input().split()) map int input().split() ().split () input split *Connect[i] Connect[i] Connect i P = list(map(int,input().split())) P list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split Switch = [0] * N Switch [0] * N [0] 0 N ans = 0 ans 0 for i in range(1<<N):
    for j in range(N):
        bit = i>>j & 1
        Switch[j] = bit
    flag = True
    for l in range(M):
        count = 0
        for c in Connect[l]:
            if Switch[c-1]:
                count+=1
        if not P[l] == count % 2:
            flag = False
    if flag:
        ans += 1 i range(1<<N) range 1<<N 1 N for j in range(N):
        bit = i>>j & 1
        Switch[j] = bit
     j range(N) range N bit = i>>j & 1 bit i>>j & 1 i>>j i j 1 Switch[j] = bit Switch[j] Switch j bit flag = True flag True for l in range(M):
        count = 0
        for c in Connect[l]:
            if Switch[c-1]:
                count+=1
        if not P[l] == count % 2:
            flag = False
     l range(M) range M count = 0 count 0 for c in Connect[l]:
            if Switch[c-1]:
                count+=1
         c Connect[l] Connect l if Switch[c-1]:
                count+=1
         Switch[c-1] Switch c-1 c 1 count+=1 count 1 if not P[l] == count % 2:
            flag = False
     not P[l] == count % 2 P[l] == count % 2 P[l] P l count % 2 count 2 flag = False flag False if flag:
        ans += 1 flag ans += 1 ans 1 print(ans) print ans N,M = map(int,input().split()) map(int,input().split()) N k, *Connect[i] = map(int,input().split()) map(int,input().split()) k flag = False False flag count = 0 0 count ans = 0 0 ans bit = i>>j & 1 i>>j & 1 bit ans += 1 1 ans P = list(map(int,input().split())) list(map(int,input().split())) P Connect = [0] * M [0] * M Connect flag = True True flag M = map(int,input().split()) map(int,input().split()) M Switch = [0] * N [0] * N Switch count+=1 1 count
N,M = map(int,input().split())
Connect = [0] * M
for i in range(M):
    k, *Connect[i] = map(int,input().split())
P = list(map(int,input().split()))
Switch = [0] * N
ans = 0
for i in range(1<<N):
    for j in range(N):
        bit = i>>j & 1
        Switch[j] = bit
    flag = True
    for l in range(M):
        count = 0
        for c in Connect[l]:
            if Switch[c-1]:
                count+=1
        if not P[l] == count % 2:
            flag = False
    if flag:
        ans += 1

print(ans)





