N, M = map(int, input().split())
k = []*M
s = []*M
for i in range(M):
    inp = list(map(int, input().split()))
    k.append(inp[0])
    s.append(inp[1:])
p = list(map(int, input().split()))

ans = 0
for i in range(0,2**N):
    n = format(i,'010b')
    for j in range(M):
        pj = 0
        for k in range(len(s[j])):
            pj += int(n[10-s[j][k]])
        if p[j] != pj%2:
            break
        if j == M-1:
            ans += 1

print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M k = []*M k []*M [] M s = []*M s []*M [] M for i in range(M):
    inp = list(map(int, input().split()))
    k.append(inp[0])
    s.append(inp[1:]) i range(M) range M inp = list(map(int, input().split())) inp list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k.append(inp[0]) k.append k append inp[0] inp 0 s.append(inp[1:]) s.append s append inp[1:] inp 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(0,2**N):
    n = format(i,'010b')
    for j in range(M):
        pj = 0
        for k in range(len(s[j])):
            pj += int(n[10-s[j][k]])
        if p[j] != pj%2:
            break
        if j == M-1:
            ans += 1 i range(0,2**N) range 0 2**N 2 N n = format(i,'010b') n format(i,'010b') format i '010b' for j in range(M):
        pj = 0
        for k in range(len(s[j])):
            pj += int(n[10-s[j][k]])
        if p[j] != pj%2:
            break
        if j == M-1:
            ans += 1 j range(M) range M pj = 0 pj 0 for k in range(len(s[j])):
            pj += int(n[10-s[j][k]])
         k range(len(s[j])) range len(s[j]) len s[j] s j pj += int(n[10-s[j][k]]) pj int(n[10-s[j][k]]) int n[10-s[j][k]] n 10-s[j][k] 10 s[j][k] [j] s j k if p[j] != pj%2:
            break
         p[j] != pj%2 p[j] p j pj%2 pj 2 break if j == M-1:
            ans += 1 j == M-1 j M-1 M 1 ans += 1 ans 1 print(ans) print ans inp = list(map(int, input().split())) list(map(int, input().split())) inp n = format(i,'010b') format(i,'010b') n M = map(int, input().split()) map(int, input().split()) M ans = 0 0 ans p = list(map(int, input().split())) list(map(int, input().split())) p ans += 1 1 ans k = []*M []*M k s = []*M []*M s pj = 0 0 pj pj += int(n[10-s[j][k]]) int(n[10-s[j][k]]) pj N, M = map(int, input().split()) map(int, input().split()) N
N, M = map(int, input().split())
k = []*M
s = []*M
for i in range(M):
    inp = list(map(int, input().split()))
    k.append(inp[0])
    s.append(inp[1:])
p = list(map(int, input().split()))

ans = 0
for i in range(0,2**N):
    n = format(i,'010b')
    for j in range(M):
        pj = 0
        for k in range(len(s[j])):
            pj += int(n[10-s[j][k]])
        if p[j] != pj%2:
            break
        if j == M-1:
            ans += 1

print(ans)