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

switch = []
for _ in range(M):
    S = list(map(int,input().split()))
    switch.append(S[1:])

P = list(map(int,input().split()))

ans = 0
for bits in range(1<<N):
    flag = True

    for i in range(M):
        cnt = 0
        for s in switch[i]:
            if(bits>>(s-1) & 1):
                cnt += 1

        if cnt % 2 != P[i]:
            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 switch = [] switch [] for _ in range(M):
    S = list(map(int,input().split()))
    switch.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 switch.append(S[1:]) switch.append switch 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 bits in range(1<<N):
    flag = True

    for i in range(M):
        cnt = 0
        for s in switch[i]:
            if(bits>>(s-1) & 1):
                cnt += 1

        if cnt % 2 != P[i]:
            flag = False
    
    if flag: ans += 1 bits range(1<<N) range 1<<N 1 N flag = True flag True for i in range(M):
        cnt = 0
        for s in switch[i]:
            if(bits>>(s-1) & 1):
                cnt += 1

        if cnt % 2 != P[i]:
            flag = False
    
     i range(M) range M cnt = 0 cnt 0 for s in switch[i]:
            if(bits>>(s-1) & 1):
                cnt += 1

         s switch[i] switch i if(bits>>(s-1) & 1):
                cnt += 1

         bits>>(s-1) & 1 bits>>(s-1) bits s-1 s 1 1 cnt += 1 cnt 1 if cnt % 2 != P[i]:
            flag = False
    
     cnt % 2 != P[i] cnt % 2 cnt 2 P[i] P i flag = False flag False if flag: ans  flag print(ans) print ans N, M = map(int,input().split()) map(int,input().split()) N flag = False False flag S = list(map(int,input().split())) list(map(int,input().split())) S cnt += 1 1 cnt switch = [] [] switch M = map(int,input().split()) map(int,input().split()) M P = list(map(int,input().split())) list(map(int,input().split())) P flag = True True flag ans = 0 0 ans cnt = 0 0 cnt
N, M = map(int,input().split())

switch = []
for _ in range(M):
    S = list(map(int,input().split()))
    switch.append(S[1:])

P = list(map(int,input().split()))

ans = 0
for bits in range(1<<N):
    flag = True

    for i in range(M):
        cnt = 0
        for s in switch[i]:
            if(bits>>(s-1) & 1):
                cnt += 1

        if cnt % 2 != P[i]:
            flag = False
    
    if flag: ans += 1

print(ans)