
N, M = map(int, input().split())
K = []
X = []
for _ in range(M):
    k, *x = list(map(int, input().split()))
    K.append(k)
    X.append(x)
P = list(map(int, input().split()))

ans = 0
for bit in range(2 ** N):
    light_on = [False] * M
    for i in range(M):
        tmp = 0
        for s in X[i]:
            tmp += bit >> (s - 1) & 1
        light_on[i] = tmp % 2 == P[i]

    ans += all(light_on)

print(ans) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M K = [] K [] X = [] X [] for _ in range(M):
    k, *x = list(map(int, input().split()))
    K.append(k)
    X.append(x) _ range(M) range M k, *x = list(map(int, input().split())) k list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split *x x K.append(k) K.append K append k X.append(x) X.append X append x 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 bit in range(2 ** N):
    light_on = [False] * M
    for i in range(M):
        tmp = 0
        for s in X[i]:
            tmp += bit >> (s - 1) & 1
        light_on[i] = tmp % 2 == P[i]

    ans += all(light_on) bit range(2 ** N) range 2 ** N 2 N light_on = [False] * M light_on [False] * M [False] False M for i in range(M):
        tmp = 0
        for s in X[i]:
            tmp += bit >> (s - 1) & 1
        light_on[i] = tmp % 2 == P[i]

     i range(M) range M tmp = 0 tmp 0 for s in X[i]:
            tmp += bit >> (s - 1) & 1
         s X[i] X i tmp += bit >> (s - 1) & 1 tmp bit >> (s - 1) & 1 bit >> (s - 1) bit s - 1 s 1 1 light_on[i] = tmp % 2 == P[i] light_on[i] light_on i tmp % 2 == P[i] tmp % 2 tmp 2 P[i] P i ans += all(light_on) ans all(light_on) all light_on print(ans) print ans P = list(map(int, input().split())) list(map(int, input().split())) P K = [] [] K ans += all(light_on) all(light_on) ans N, M = map(int, input().split()) map(int, input().split()) N light_on = [False] * M [False] * M light_on tmp += bit >> (s - 1) & 1 bit >> (s - 1) & 1 tmp ans = 0 0 ans M = map(int, input().split()) map(int, input().split()) M k, *x = list(map(int, input().split())) list(map(int, input().split())) k X = [] [] X tmp = 0 0 tmp

N, M = map(int, input().split())
K = []
X = []
for _ in range(M):
    k, *x = list(map(int, input().split()))
    K.append(k)
    X.append(x)
P = list(map(int, input().split()))

ans = 0
for bit in range(2 ** N):
    light_on = [False] * M
    for i in range(M):
        tmp = 0
        for s in X[i]:
            tmp += bit >> (s - 1) & 1
        light_on[i] = tmp % 2 == P[i]

    ans += all(light_on)

print(ans)
