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

s_list = []
for i in range(M):
    s_list.append(list(map(int, input().split())))
P_list = list(map(int, input().split()))

ans = 0
for i in range(1 << N):
    S = ["OFF" for _ in range(N)]
    for j in range(N):
        if (i >> j) & 1 == 1:
            S[j] = "ON"
    m = 0
    while True:
        cnt = 0
        for s in range(1, len(s_list[m])):
            if S[s_list[m][s]-1] == "ON":
                cnt += 1
        if cnt % 2 != P_list[m]:
            break
        m += 1
        if m == M:
            break
    if m == M:
        ans += 1
print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M s_list = [] s_list [] for i in range(M):
    s_list.append(list(map(int, input().split()))) i range(M) range M s_list.append(list(map(int, input().split()))) s_list.append s_list append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split P_list = list(map(int, input().split())) P_list list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for i in range(1 << N):
    S = ["OFF" for _ in range(N)]
    for j in range(N):
        if (i >> j) & 1 == 1:
            S[j] = "ON"
    m = 0
    while True:
        cnt = 0
        for s in range(1, len(s_list[m])):
            if S[s_list[m][s]-1] == "ON":
                cnt += 1
        if cnt % 2 != P_list[m]:
            break
        m += 1
        if m == M:
            break
    if m == M:
        ans += 1 i range(1 << N) range 1 << N 1 N "OFF" for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) "OFF" S = ["OFF" for _ in range(N)] S ["OFF" for _ in range(N)] for j in range(N):
        if (i >> j) & 1 == 1:
            S[j] = "ON"
     j range(N) range N if (i >> j) & 1 == 1:
            S[j] = "ON"
     (i >> j) & 1 == 1 (i >> j) & 1 i >> j i j 1 1 S[j] = "ON" S[j] S j "ON" m = 0 m 0 while True:
        cnt = 0
        for s in range(1, len(s_list[m])):
            if S[s_list[m][s]-1] == "ON":
                cnt += 1
        if cnt % 2 != P_list[m]:
            break
        m += 1
        if m == M:
            break
     True cnt = 0 cnt 0 for s in range(1, len(s_list[m])):
            if S[s_list[m][s]-1] == "ON":
                cnt += 1
         s range(1, len(s_list[m])) range 1 len(s_list[m]) len s_list[m] s_list m if S[s_list[m][s]-1] == "ON":
                cnt += 1
         S[s_list[m][s]-1] == "ON" S[s_list[m][s]-1] S s_list[m][s]-1 s_list[m][s] [m] s_list m s 1 "ON" cnt += 1 cnt 1 if cnt % 2 != P_list[m]:
            break
         cnt % 2 != P_list[m] cnt % 2 cnt 2 P_list[m] P_list m break m += 1 m 1 if m == M:
            break
     m == M m M break if m == M:
        ans += 1 m == M m M ans += 1 ans 1 print(ans) print ans cnt = 0 0 cnt cnt += 1 1 cnt ans += 1 1 ans M = map(int, input().split()) map(int, input().split()) M ans = 0 0 ans P_list = list(map(int, input().split())) list(map(int, input().split())) P_list m += 1 1 m s_list = [] [] s_list N, M = map(int, input().split()) map(int, input().split()) N S = ["OFF" for _ in range(N)] ["OFF" for _ in range(N)] S m = 0 0 m
N, M = map(int, input().split())

s_list = []
for i in range(M):
    s_list.append(list(map(int, input().split())))
P_list = list(map(int, input().split()))

ans = 0
for i in range(1 << N):
    S = ["OFF" for _ in range(N)]
    for j in range(N):
        if (i >> j) & 1 == 1:
            S[j] = "ON"
    m = 0
    while True:
        cnt = 0
        for s in range(1, len(s_list[m])):
            if S[s_list[m][s]-1] == "ON":
                cnt += 1
        if cnt % 2 != P_list[m]:
            break
        m += 1
        if m == M:
            break
    if m == M:
        ans += 1
print(ans)
