N, M = map(int, input().split())
bulbs = []
for _ in range(M):
    b = tuple(map(int, input().split()))
    bulbs.append(b[1:])
P = list(map(int, input().split()))

ans = 0
for switch in range(2**N):
    check = [False] * M
    for i ,bulb in enumerate(bulbs):
        count = 0
        for b in bulb:
            if switch >> (b-1) & 1:
                count += 1
        if count % 2 ==P[i]:
            check[i] = True
        else:
            check[i] = False
    if all(check):
        ans += 1
print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M bulbs = [] bulbs [] for _ in range(M):
    b = tuple(map(int, input().split()))
    bulbs.append(b[1:]) _ range(M) range M b = tuple(map(int, input().split())) b tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split bulbs.append(b[1:]) bulbs.append bulbs append b[1:] b 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 switch in range(2**N):
    check = [False] * M
    for i ,bulb in enumerate(bulbs):
        count = 0
        for b in bulb:
            if switch >> (b-1) & 1:
                count += 1
        if count % 2 ==P[i]:
            check[i] = True
        else:
            check[i] = False
    if all(check):
        ans += 1 switch range(2**N) range 2**N 2 N check = [False] * M check [False] * M [False] False M for i ,bulb in enumerate(bulbs):
        count = 0
        for b in bulb:
            if switch >> (b-1) & 1:
                count += 1
        if count % 2 ==P[i]:
            check[i] = True
        else:
            check[i] = False
     i bulb enumerate(bulbs) enumerate bulbs count = 0 count 0 for b in bulb:
            if switch >> (b-1) & 1:
                count += 1
         b bulb if switch >> (b-1) & 1:
                count += 1
         switch >> (b-1) & 1 switch >> (b-1) switch b-1 b 1 1 count += 1 count 1 if count % 2 ==P[i]:
            check[i] = True
        else:
            check[i] = False
     count % 2 ==P[i] count % 2 count 2 P[i] P i check[i] = True check[i] check i True check[i] = False check[i] check i False if all(check):
        ans += 1 all(check) all check ans += 1 ans 1 print(ans) print ans N, M = map(int, input().split()) map(int, input().split()) N count += 1 1 count check = [False] * M [False] * M check bulbs = [] [] bulbs M = map(int, input().split()) map(int, input().split()) M ans = 0 0 ans ans += 1 1 ans P = list(map(int, input().split())) list(map(int, input().split())) P b = tuple(map(int, input().split())) tuple(map(int, input().split())) b count = 0 0 count
N, M = map(int, input().split())
bulbs = []
for _ in range(M):
    b = tuple(map(int, input().split()))
    bulbs.append(b[1:])
P = list(map(int, input().split()))

ans = 0
for switch in range(2**N):
    check = [False] * M
    for i ,bulb in enumerate(bulbs):
        count = 0
        for b in bulb:
            if switch >> (b-1) & 1:
                count += 1
        if count % 2 ==P[i]:
            check[i] = True
        else:
            check[i] = False
    if all(check):
        ans += 1
print(ans)