N, M = map(int, input().split())
lamp = []
for _ in range(M):
    lamp.append(list(map(int, input().split()))[1:])
P = list(map(int, input().split()))
res = 0
for bit in range(1<<N):
    on = 0
    for l in range(M):
        temp = 0
        for i in lamp[l]:
            i -= 1
            if (bit >> i) & 1 == 1:
                temp += 1
        if temp%2 == P[l]:
            on += 1
    if on == M:
        res += 1
print(res) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M lamp = [] lamp [] for _ in range(M):
    lamp.append(list(map(int, input().split()))[1:]) _ range(M) range M lamp.append(list(map(int, input().split()))[1:]) lamp.append lamp append list(map(int, input().split()))[1:] (map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 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 res = 0 res 0 for bit in range(1<<N):
    on = 0
    for l in range(M):
        temp = 0
        for i in lamp[l]:
            i -= 1
            if (bit >> i) & 1 == 1:
                temp += 1
        if temp%2 == P[l]:
            on += 1
    if on == M:
        res += 1 bit range(1<<N) range 1<<N 1 N on = 0 on 0 for l in range(M):
        temp = 0
        for i in lamp[l]:
            i -= 1
            if (bit >> i) & 1 == 1:
                temp += 1
        if temp%2 == P[l]:
            on += 1
     l range(M) range M temp = 0 temp 0 for i in lamp[l]:
            i -= 1
            if (bit >> i) & 1 == 1:
                temp += 1
         i lamp[l] lamp l i -= 1 i 1 if (bit >> i) & 1 == 1:
                temp += 1
         (bit >> i) & 1 == 1 (bit >> i) & 1 bit >> i bit i 1 1 temp += 1 temp 1 if temp%2 == P[l]:
            on += 1
     temp%2 == P[l] temp%2 temp 2 P[l] P l on += 1 on 1 if on == M:
        res += 1 on == M on M res += 1 res 1 print(res) print res res += 1 1 res N, M = map(int, input().split()) map(int, input().split()) N on = 0 0 on temp += 1 1 temp on += 1 1 on lamp = [] [] lamp P = list(map(int, input().split())) list(map(int, input().split())) P res = 0 0 res i -= 1 1 i M = map(int, input().split()) map(int, input().split()) M temp = 0 0 temp
N, M = map(int, input().split())
lamp = []
for _ in range(M):
    lamp.append(list(map(int, input().split()))[1:])
P = list(map(int, input().split()))
res = 0
for bit in range(1<<N):
    on = 0
    for l in range(M):
        temp = 0
        for i in lamp[l]:
            i -= 1
            if (bit >> i) & 1 == 1:
                temp += 1
        if temp%2 == P[l]:
            on += 1
    if on == M:
        res += 1
print(res)