from collections import defaultdict
N, M = map(int, input().split())

connection = {}
for i in range(M):
    line = list(map(int, input().split()))
    s = line[1:]
    connection[i] = s

P = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    isSwitchOn = [0 for _ in range(N)]
    for j in range(N):
        if (i >> j) & 1:
            isSwitchOn[j] = 1

    onBulbs = 0
    for j in range(M):
        count = 0
        for switch in connection[j]:
            if isSwitchOn[switch-1]:
                count += 1

        if count % 2 == P[j]:
            onBulbs += 1

    if onBulbs == M:
        ans += 1

print(ans) from collections import defaultdict N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M connection = {} connection {} for i in range(M):
    line = list(map(int, input().split()))
    s = line[1:]
    connection[i] = s i range(M) range M line = list(map(int, input().split())) line list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split s = line[1:] s line[1:] line 1: 1 connection[i] = s connection[i] connection i s 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(2**N):
    isSwitchOn = [0 for _ in range(N)]
    for j in range(N):
        if (i >> j) & 1:
            isSwitchOn[j] = 1

    onBulbs = 0
    for j in range(M):
        count = 0
        for switch in connection[j]:
            if isSwitchOn[switch-1]:
                count += 1

        if count % 2 == P[j]:
            onBulbs += 1

    if onBulbs == M:
        ans += 1 i range(2**N) range 2**N 2 N 0 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 0 isSwitchOn = [0 for _ in range(N)] isSwitchOn [0 for _ in range(N)] for j in range(N):
        if (i >> j) & 1:
            isSwitchOn[j] = 1

     j range(N) range N if (i >> j) & 1:
            isSwitchOn[j] = 1

     (i >> j) & 1 i >> j i j 1 isSwitchOn[j] = 1 isSwitchOn[j] isSwitchOn j 1 onBulbs = 0 onBulbs 0 for j in range(M):
        count = 0
        for switch in connection[j]:
            if isSwitchOn[switch-1]:
                count += 1

        if count % 2 == P[j]:
            onBulbs += 1

     j range(M) range M count = 0 count 0 for switch in connection[j]:
            if isSwitchOn[switch-1]:
                count += 1

         switch connection[j] connection j if isSwitchOn[switch-1]:
                count += 1

         isSwitchOn[switch-1] isSwitchOn switch-1 switch 1 count += 1 count 1 if count % 2 == P[j]:
            onBulbs += 1

     count % 2 == P[j] count % 2 count 2 P[j] P j onBulbs += 1 onBulbs 1 if onBulbs == M:
        ans += 1 onBulbs == M onBulbs M ans += 1 ans 1 print(ans) print ans ans = 0 0 ans line = list(map(int, input().split())) list(map(int, input().split())) line P = list(map(int, input().split())) list(map(int, input().split())) P ans += 1 1 ans N, M = map(int, input().split()) map(int, input().split()) N isSwitchOn = [0 for _ in range(N)] [0 for _ in range(N)] isSwitchOn count += 1 1 count onBulbs = 0 0 onBulbs M = map(int, input().split()) map(int, input().split()) M count = 0 0 count connection = {} {} connection onBulbs += 1 1 onBulbs s = line[1:] line[1:] s
from collections import defaultdict
N, M = map(int, input().split())

connection = {}
for i in range(M):
    line = list(map(int, input().split()))
    s = line[1:]
    connection[i] = s

P = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    isSwitchOn = [0 for _ in range(N)]
    for j in range(N):
        if (i >> j) & 1:
            isSwitchOn[j] = 1

    onBulbs = 0
    for j in range(M):
        count = 0
        for switch in connection[j]:
            if isSwitchOn[switch-1]:
                count += 1

        if count % 2 == P[j]:
            onBulbs += 1

    if onBulbs == M:
        ans += 1

print(ans)
