#!/usr/bin/python3
#coding: utf-8

N, M = (int(x) for x in input().split())

S = []
for i in range(M):
    items = [int(x)-1 for x in input().split()]
    S.append(items[1:])

P = [int(x) for x in input().split()]

ret = 0
for bit in range(2**N):
    on = [i for i in range(N) if bit & (1 << i)]
    ok = True
    for i in range(M):
        s = S[i]
        p = P[i]
        if sum(1 for switch in s if switch in on) % 2 != p:
            ok = False
            break
    if ok:
        ret += 1
print(ret) int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x N, M = (int(x) for x in input().split()) N (int(x) for x in input().split()) M S = [] S [] for i in range(M):
    items = [int(x)-1 for x in input().split()]
    S.append(items[1:]) i range(M) range M int(x)-1 for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x)-1 int(x) int x 1 items = [int(x)-1 for x in input().split()] items [int(x)-1 for x in input().split()] S.append(items[1:]) S.append S append items[1:] items 1: 1 int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x P = [int(x) for x in input().split()] P [int(x) for x in input().split()] ret = 0 ret 0 for bit in range(2**N):
    on = [i for i in range(N) if bit & (1 << i)]
    ok = True
    for i in range(M):
        s = S[i]
        p = P[i]
        if sum(1 for switch in s if switch in on) % 2 != p:
            ok = False
            break
    if ok:
        ret += 1 bit range(2**N) range 2**N 2 N i for i in range(N) if bit & (1 << i) for i in range(N) if bit & (1 << i) i range(N) range N bit & (1 << i) bit 1 << i 1 i if bit & (1 << i) i on = [i for i in range(N) if bit & (1 << i)] on [i for i in range(N) if bit & (1 << i)] ok = True ok True for i in range(M):
        s = S[i]
        p = P[i]
        if sum(1 for switch in s if switch in on) % 2 != p:
            ok = False
            break
     i range(M) range M s = S[i] s S[i] S i p = P[i] p P[i] P i if sum(1 for switch in s if switch in on) % 2 != p:
            ok = False
            break
     sum(1 for switch in s if switch in on) % 2 != p sum(1 for switch in s if switch in on) % 2 sum(1 for switch in s if switch in on) sum 1 2 p ok = False ok False break if ok:
        ret += 1 ok ret += 1 ret 1 print(ret) print ret ok = True True ok P = [int(x) for x in input().split()] [int(x) for x in input().split()] P ret = 0 0 ret ret += 1 1 ret M = (int(x) for x in input().split()) (int(x) for x in input().split()) M on = [i for i in range(N) if bit & (1 << i)] [i for i in range(N) if bit & (1 << i)] on s = S[i] S[i] s p = P[i] P[i] p items = [int(x)-1 for x in input().split()] [int(x)-1 for x in input().split()] items ok = False False ok N, M = (int(x) for x in input().split()) (int(x) for x in input().split()) N S = [] [] S
#!/usr/bin/python3
#coding: utf-8

N, M = (int(x) for x in input().split())

S = []
for i in range(M):
    items = [int(x)-1 for x in input().split()]
    S.append(items[1:])

P = [int(x) for x in input().split()]

ret = 0
for bit in range(2**N):
    on = [i for i in range(N) if bit & (1 << i)]
    ok = True
    for i in range(M):
        s = S[i]
        p = P[i]
        if sum(1 for switch in s if switch in on) % 2 != p:
            ok = False
            break
    if ok:
        ret += 1
print(ret)
