import sys

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N, M = NMI()
    KS = [NLI() for _ in range(M)]
    P = NLI()
    
    ans = 0
    
    for m in range(M):
        for x in range(1,len(KS[m])):
            KS[m][x] -= 1

    bit_len = N
    for i in range(2**bit_len):
        switch = [0 for _ in range(bit_len)]
        for j in range(bit_len):
            if (i >> j) & 1:
                switch[j] = 1
        
        light = [0 for _ in range(M)]
        
        for m in range(M):
            cnt = 0
            for y in KS[m][1:]:
                if switch[y] == 1:
                    cnt += 1
            if cnt % 2 == P[m]:
                light[m] = 1
        
        if light.count(1) == M:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main() import sys sys sys.setrecursionlimit(1000000) sys.setrecursionlimit sys setrecursionlimit 1000000 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 input = lambda: sys.stdin.readline().strip() input lambda: sys.stdin.readline().strip() sys.stdin.readline().strip() sys.stdin.readline().strip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline strip NI = lambda: int(input()) NI lambda: int(input()) int(input()) int input() input NMI = lambda: map(int, input().split()) NMI lambda: map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split NLI = lambda: list(NMI()) NLI lambda: list(NMI()) list(NMI()) list NMI() NMI SI = lambda: input() SI lambda: input() input() input def main():
    N, M = NMI()
    KS = [NLI() for _ in range(M)]
    P = NLI()
    
    ans = 0
    
    for m in range(M):
        for x in range(1,len(KS[m])):
            KS[m][x] -= 1

    bit_len = N
    for i in range(2**bit_len):
        switch = [0 for _ in range(bit_len)]
        for j in range(bit_len):
            if (i >> j) & 1:
                switch[j] = 1
        
        light = [0 for _ in range(M)]
        
        for m in range(M):
            cnt = 0
            for y in KS[m][1:]:
                if switch[y] == 1:
                    cnt += 1
            if cnt % 2 == P[m]:
                light[m] = 1
        
        if light.count(1) == M:
            ans += 1
    print(ans) main N, M = NMI() N NMI() NMI M NLI() for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) NLI() NLI KS = [NLI() for _ in range(M)] KS [NLI() for _ in range(M)] P = NLI() P NLI() NLI ans = 0 ans 0 for m in range(M):
        for x in range(1,len(KS[m])):
            KS[m][x] -= 1

     m range(M) range M for x in range(1,len(KS[m])):
            KS[m][x] -= 1

     x range(1,len(KS[m])) range 1 len(KS[m]) len KS[m] KS m KS[m][x] -= 1 KS[m][x] [m] KS m x 1 bit_len = N bit_len N for i in range(2**bit_len):
        switch = [0 for _ in range(bit_len)]
        for j in range(bit_len):
            if (i >> j) & 1:
                switch[j] = 1
        
        light = [0 for _ in range(M)]
        
        for m in range(M):
            cnt = 0
            for y in KS[m][1:]:
                if switch[y] == 1:
                    cnt += 1
            if cnt % 2 == P[m]:
                light[m] = 1
        
        if light.count(1) == M:
            ans += 1
     i range(2**bit_len) range 2**bit_len 2 bit_len 0 for _ in range(bit_len) for _ in range(bit_len) _ range(bit_len) range bit_len for _ in range(bit_len) 0 switch = [0 for _ in range(bit_len)] switch [0 for _ in range(bit_len)] for j in range(bit_len):
            if (i >> j) & 1:
                switch[j] = 1
        
         j range(bit_len) range bit_len if (i >> j) & 1:
                switch[j] = 1
        
         (i >> j) & 1 i >> j i j 1 switch[j] = 1 switch[j] switch j 1 0 for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) 0 light = [0 for _ in range(M)] light [0 for _ in range(M)] for m in range(M):
            cnt = 0
            for y in KS[m][1:]:
                if switch[y] == 1:
                    cnt += 1
            if cnt % 2 == P[m]:
                light[m] = 1
        
         m range(M) range M cnt = 0 cnt 0 for y in KS[m][1:]:
                if switch[y] == 1:
                    cnt += 1
             y KS[m][1:] [m] KS m 1: 1 if switch[y] == 1:
                    cnt += 1
             switch[y] == 1 switch[y] switch y 1 cnt += 1 cnt 1 if cnt % 2 == P[m]:
                light[m] = 1
        
         cnt % 2 == P[m] cnt % 2 cnt 2 P[m] P m light[m] = 1 light[m] light m 1 if light.count(1) == M:
            ans += 1
     light.count(1) == M light.count(1) light.count light count 1 M ans += 1 ans 1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main input = lambda: sys.stdin.readline().strip() lambda: sys.stdin.readline().strip() input MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD NLI = lambda: list(NMI()) lambda: list(NMI()) NLI NI = lambda: int(input()) lambda: int(input()) NI SI = lambda: input() lambda: input() SI NMI = lambda: map(int, input().split()) lambda: map(int, input().split()) NMI def main():
    N, M = NMI()
    KS = [NLI() for _ in range(M)]
    P = NLI()
    
    ans = 0
    
    for m in range(M):
        for x in range(1,len(KS[m])):
            KS[m][x] -= 1

    bit_len = N
    for i in range(2**bit_len):
        switch = [0 for _ in range(bit_len)]
        for j in range(bit_len):
            if (i >> j) & 1:
                switch[j] = 1
        
        light = [0 for _ in range(M)]
        
        for m in range(M):
            cnt = 0
            for y in KS[m][1:]:
                if switch[y] == 1:
                    cnt += 1
            if cnt % 2 == P[m]:
                light[m] = 1
        
        if light.count(1) == M:
            ans += 1
    print(ans) def main():
    N, M = NMI()
    KS = [NLI() for _ in range(M)]
    P = NLI()
    
    ans = 0
    
    for m in range(M):
        for x in range(1,len(KS[m])):
            KS[m][x] -= 1

    bit_len = N
    for i in range(2**bit_len):
        switch = [0 for _ in range(bit_len)]
        for j in range(bit_len):
            if (i >> j) & 1:
                switch[j] = 1
        
        light = [0 for _ in range(M)]
        
        for m in range(M):
            cnt = 0
            for y in KS[m][1:]:
                if switch[y] == 1:
                    cnt += 1
            if cnt % 2 == P[m]:
                light[m] = 1
        
        if light.count(1) == M:
            ans += 1
    print(ans) main
import sys

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N, M = NMI()
    KS = [NLI() for _ in range(M)]
    P = NLI()
    
    ans = 0
    
    for m in range(M):
        for x in range(1,len(KS[m])):
            KS[m][x] -= 1

    bit_len = N
    for i in range(2**bit_len):
        switch = [0 for _ in range(bit_len)]
        for j in range(bit_len):
            if (i >> j) & 1:
                switch[j] = 1
        
        light = [0 for _ in range(M)]
        
        for m in range(M):
            cnt = 0
            for y in KS[m][1:]:
                if switch[y] == 1:
                    cnt += 1
            if cnt % 2 == P[m]:
                light[m] = 1
        
        if light.count(1) == M:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()