# 93 C - Switches
N,M = map(int,input().split())
K = []
S = []
for _ in range(M):
    s = list(map(int,input().split())) 
    K.append(s[0])
    # 0-indexed
    s = [i-1 for i in s]
    S.append(s[1:])
P = list(map(int,input().split()))

ans = 0
for i in range(1<<N):
    swiches = [0]*N
    for j in range(N):
        mask = 1<<j
        # j 番目のスイッチが on のとき
        if i & mask != 0:
            swiches[j] = 1
        # j 番目のスイッチが off のとき
        else:
            continue

    # on の電球をカウント
    cnt_light = 0
    for m in range(M):
        cnt_swich = 0
        for s in S[m]:
            if swiches[s] == 1:
                cnt_swich += 1
        if cnt_swich%2 == P[m]:
            cnt_light += 1
    if cnt_light == M:
        ans += 1
print(ans) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M K = [] K [] S = [] S [] for _ in range(M):
    s = list(map(int,input().split())) 
    K.append(s[0])
    # 0-indexed
    s = [i-1 for i in s]
    S.append(s[1:]) _ range(M) range M s = list(map(int,input().split())) s list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split K.append(s[0]) K.append K append s[0] s 0 i-1 for i in s for i in s i s for i in s i-1 i 1 s = [i-1 for i in s] s [i-1 for i in s] S.append(s[1:]) S.append S append s[1:] s 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 ans = 0 ans 0 for i in range(1<<N):
    swiches = [0]*N
    for j in range(N):
        mask = 1<<j
        # j 番目のスイッチが on のとき
        if i & mask != 0:
            swiches[j] = 1
        # j 番目のスイッチが off のとき
        else:
            continue

    # on の電球をカウント
    cnt_light = 0
    for m in range(M):
        cnt_swich = 0
        for s in S[m]:
            if swiches[s] == 1:
                cnt_swich += 1
        if cnt_swich%2 == P[m]:
            cnt_light += 1
    if cnt_light == M:
        ans += 1 i range(1<<N) range 1<<N 1 N swiches = [0]*N swiches [0]*N [0] 0 N for j in range(N):
        mask = 1<<j
        # j 番目のスイッチが on のとき
        if i & mask != 0:
            swiches[j] = 1
        # j 番目のスイッチが off のとき
        else:
            continue

    # on の電球をカウント
     j range(N) range N mask = 1<<j mask 1<<j 1 j if i & mask != 0:
            swiches[j] = 1
        # j 番目のスイッチが off のとき
        else:
            continue

    # on の電球をカウント
     i & mask != 0 i & mask i mask 0 swiches[j] = 1 swiches[j] swiches j 1 continue cnt_light = 0 cnt_light 0 for m in range(M):
        cnt_swich = 0
        for s in S[m]:
            if swiches[s] == 1:
                cnt_swich += 1
        if cnt_swich%2 == P[m]:
            cnt_light += 1
     m range(M) range M cnt_swich = 0 cnt_swich 0 for s in S[m]:
            if swiches[s] == 1:
                cnt_swich += 1
         s S[m] S m if swiches[s] == 1:
                cnt_swich += 1
         swiches[s] == 1 swiches[s] swiches s 1 cnt_swich += 1 cnt_swich 1 if cnt_swich%2 == P[m]:
            cnt_light += 1
     cnt_swich%2 == P[m] cnt_swich%2 cnt_swich 2 P[m] P m cnt_light += 1 cnt_light 1 if cnt_light == M:
        ans += 1 cnt_light == M cnt_light M ans += 1 ans 1 print(ans) print ans mask = 1<<j 1<<j mask ans += 1 1 ans M = map(int,input().split()) map(int,input().split()) M S = [] [] S cnt_swich += 1 1 cnt_swich P = list(map(int,input().split())) list(map(int,input().split())) P s = list(map(int,input().split())) list(map(int,input().split())) s swiches = [0]*N [0]*N swiches N,M = map(int,input().split()) map(int,input().split()) N s = [i-1 for i in s] [i-1 for i in s] s cnt_light = 0 0 cnt_light ans = 0 0 ans cnt_light += 1 1 cnt_light cnt_swich = 0 0 cnt_swich K = [] [] K
# 93 C - Switches
N,M = map(int,input().split())
K = []
S = []
for _ in range(M):
    s = list(map(int,input().split())) 
    K.append(s[0])
    # 0-indexed
    s = [i-1 for i in s]
    S.append(s[1:])
P = list(map(int,input().split()))

ans = 0
for i in range(1<<N):
    swiches = [0]*N
    for j in range(N):
        mask = 1<<j
        # j 番目のスイッチが on のとき
        if i & mask != 0:
            swiches[j] = 1
        # j 番目のスイッチが off のとき
        else:
            continue

    # on の電球をカウント
    cnt_light = 0
    for m in range(M):
        cnt_swich = 0
        for s in S[m]:
            if swiches[s] == 1:
                cnt_swich += 1
        if cnt_swich%2 == P[m]:
            cnt_light += 1
    if cnt_light == M:
        ans += 1
print(ans)