n, m = map(int, input().split())
light = []
for i in range(m):
    tmp = list(map(int, input().split()))
    light.append(tmp[1:])
p = list(map(int, input().split()))
ans = 0
# 0 off, 1 on, bit全探索
for mask in range(1 << n):
    # print(mask)
    out = False
    # それぞれの電球について見る
    for i in range(len(light)):
        cnt = 0
        # 各電球が点くかを見たい
        for check in light[i]:
            if mask >> (check - 1) & 1:
                cnt += 1
        if cnt % 2 != p[i]:
            out = True
            break
    if not out:
        ans += 1

print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m light = [] light [] for i in range(m):
    tmp = list(map(int, input().split()))
    light.append(tmp[1:]) i range(m) range m tmp = list(map(int, input().split())) tmp list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split light.append(tmp[1:]) light.append light append tmp[1:] tmp 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 mask in range(1 << n):
    # print(mask)
    out = False
    # それぞれの電球について見る
    for i in range(len(light)):
        cnt = 0
        # 各電球が点くかを見たい
        for check in light[i]:
            if mask >> (check - 1) & 1:
                cnt += 1
        if cnt % 2 != p[i]:
            out = True
            break
    if not out:
        ans += 1 mask range(1 << n) range 1 << n 1 n out = False out False for i in range(len(light)):
        cnt = 0
        # 各電球が点くかを見たい
        for check in light[i]:
            if mask >> (check - 1) & 1:
                cnt += 1
        if cnt % 2 != p[i]:
            out = True
            break
     i range(len(light)) range len(light) len light cnt = 0 cnt 0 for check in light[i]:
            if mask >> (check - 1) & 1:
                cnt += 1
         check light[i] light i if mask >> (check - 1) & 1:
                cnt += 1
         mask >> (check - 1) & 1 mask >> (check - 1) mask check - 1 check 1 1 cnt += 1 cnt 1 if cnt % 2 != p[i]:
            out = True
            break
     cnt % 2 != p[i] cnt % 2 cnt 2 p[i] p i out = True out True break if not out:
        ans += 1 not out out ans += 1 ans 1 print(ans) print ans out = False False out cnt = 0 0 cnt tmp = list(map(int, input().split())) list(map(int, input().split())) tmp light = [] [] light n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m ans += 1 1 ans p = list(map(int, input().split())) list(map(int, input().split())) p out = True True out ans = 0 0 ans cnt += 1 1 cnt
n, m = map(int, input().split())
light = []
for i in range(m):
    tmp = list(map(int, input().split()))
    light.append(tmp[1:])
p = list(map(int, input().split()))
ans = 0
# 0 off, 1 on, bit全探索
for mask in range(1 << n):
    # print(mask)
    out = False
    # それぞれの電球について見る
    for i in range(len(light)):
        cnt = 0
        # 各電球が点くかを見たい
        for check in light[i]:
            if mask >> (check - 1) & 1:
                cnt += 1
        if cnt % 2 != p[i]:
            out = True
            break
    if not out:
        ans += 1

print(ans)
