n, m = map(int, input().split())
Q = []
for _ in range(m):
    q = list(map(int, input().split()))
    Q.append(q)
p = list(map(int, input().split()))
ans = 0
#　全てのスイッチパターンを列挙
for pattern in range(2 ** n):
    #p = bin(p)
    for i in range(len(Q)):
        on_cnt = 0
        for j in range(1, len(Q[i])):
            if ((pattern >> (Q[i][j] - 1)) & 1):
                on_cnt += 1
        if on_cnt % 2 != p[i]:
            break
    else:
        ans += 1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m Q = [] Q [] for _ in range(m):
    q = list(map(int, input().split()))
    Q.append(q) _ range(m) range m q = list(map(int, input().split())) q list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split Q.append(q) Q.append Q append q 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 pattern in range(2 ** n):
    #p = bin(p)
    for i in range(len(Q)):
        on_cnt = 0
        for j in range(1, len(Q[i])):
            if ((pattern >> (Q[i][j] - 1)) & 1):
                on_cnt += 1
        if on_cnt % 2 != p[i]:
            break
    else:
        ans += 1 pattern range(2 ** n) range 2 ** n 2 n for i in range(len(Q)):
        on_cnt = 0
        for j in range(1, len(Q[i])):
            if ((pattern >> (Q[i][j] - 1)) & 1):
                on_cnt += 1
        if on_cnt % 2 != p[i]:
            break
    else:
        ans += 1 i range(len(Q)) range len(Q) len Q on_cnt = 0 on_cnt 0 for j in range(1, len(Q[i])):
            if ((pattern >> (Q[i][j] - 1)) & 1):
                on_cnt += 1
         j range(1, len(Q[i])) range 1 len(Q[i]) len Q[i] Q i if ((pattern >> (Q[i][j] - 1)) & 1):
                on_cnt += 1
         (pattern >> (Q[i][j] - 1)) & 1 pattern >> (Q[i][j] - 1) pattern Q[i][j] - 1 Q[i][j] [i] Q i j 1 1 on_cnt += 1 on_cnt 1 if on_cnt % 2 != p[i]:
            break
     on_cnt % 2 != p[i] on_cnt % 2 on_cnt 2 p[i] p i break ans += 1 ans 1 print(ans) print ans n, m = map(int, input().split()) map(int, input().split()) n on_cnt = 0 0 on_cnt on_cnt += 1 1 on_cnt m = map(int, input().split()) map(int, input().split()) m Q = [] [] Q p = list(map(int, input().split())) list(map(int, input().split())) p ans = 0 0 ans q = list(map(int, input().split())) list(map(int, input().split())) q ans += 1 1 ans
n, m = map(int, input().split())
Q = []
for _ in range(m):
    q = list(map(int, input().split()))
    Q.append(q)
p = list(map(int, input().split()))
ans = 0
#　全てのスイッチパターンを列挙
for pattern in range(2 ** n):
    #p = bin(p)
    for i in range(len(Q)):
        on_cnt = 0
        for j in range(1, len(Q[i])):
            if ((pattern >> (Q[i][j] - 1)) & 1):
                on_cnt += 1
        if on_cnt % 2 != p[i]:
            break
    else:
        ans += 1
print(ans)
