n, m = map(int, input().split())

smi = [ None ] * m

for i in range(m):
    k, *si = map(lambda x: int(x) - 1, input().split())

    smi[i] = si

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

def emitable(bit_pattern, i):
    si = smi[i]
    px = pi[i]
    py = 0

    for s in si:
        py += (bit_pattern & (2 ** s)) >> s

    return px == (py % 2)

count = 0

for bi in range(2 ** n):
    if all(emitable(bi, i) for i in range(m)):
        count += 1

print(count) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m smi = [ None ] * m smi [ None ] * m [ None ] None m for i in range(m):
    k, *si = map(lambda x: int(x) - 1, input().split())

    smi[i] = si i range(m) range m k, *si = map(lambda x: int(x) - 1, input().split()) k map(lambda x: int(x) - 1, input().split()) map lambda x: int(x) - 1 int(x) - 1 int(x) int x 1 x input().split() ().split () input split *si si smi[i] = si smi[i] smi i si pi = list(map(int, input().split())) pi list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split def emitable(bit_pattern, i):
    si = smi[i]
    px = pi[i]
    py = 0

    for s in si:
        py += (bit_pattern & (2 ** s)) >> s

    return px == (py % 2) emitable si = smi[i] si smi[i] smi i px = pi[i] px pi[i] pi i py = 0 py 0 for s in si:
        py += (bit_pattern & (2 ** s)) >> s

     s si py += (bit_pattern & (2 ** s)) >> s py (bit_pattern & (2 ** s)) >> s bit_pattern & (2 ** s) bit_pattern 2 ** s 2 s s return px == (py % 2) px == (py % 2) px py % 2 py 2 bit_pattern bit_pattern i i count = 0 count 0 for bi in range(2 ** n):
    if all(emitable(bi, i) for i in range(m)):
        count += 1 bi range(2 ** n) range 2 ** n 2 n if all(emitable(bi, i) for i in range(m)):
        count += 1 all(emitable(bi, i) for i in range(m)) all emitable(bi, i) emitable bi i count += 1 count 1 print(count) print count count += 1 1 count def emitable(bit_pattern, i):
    si = smi[i]
    px = pi[i]
    py = 0

    for s in si:
        py += (bit_pattern & (2 ** s)) >> s

    return px == (py % 2) def emitable(bit_pattern, i):
    si = smi[i]
    px = pi[i]
    py = 0

    for s in si:
        py += (bit_pattern & (2 ** s)) >> s

    return px == (py % 2) emitable smi = [ None ] * m [ None ] * m smi n, m = map(int, input().split()) map(int, input().split()) n count = 0 0 count k, *si = map(lambda x: int(x) - 1, input().split()) map(lambda x: int(x) - 1, input().split()) k m = map(int, input().split()) map(int, input().split()) m pi = list(map(int, input().split())) list(map(int, input().split())) pi
n, m = map(int, input().split())

smi = [ None ] * m

for i in range(m):
    k, *si = map(lambda x: int(x) - 1, input().split())

    smi[i] = si

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

def emitable(bit_pattern, i):
    si = smi[i]
    px = pi[i]
    py = 0

    for s in si:
        py += (bit_pattern & (2 ** s)) >> s

    return px == (py % 2)

count = 0

for bi in range(2 ** n):
    if all(emitable(bi, i) for i in range(m)):
        count += 1

print(count)