n, m = map(int, input().split())
k = []
s = []
for _ in range(m):
    ks = list(map(int, input().split()))
    _k = ks[0]
    _s = [ks[i] for i in range(1, len(ks))]
    k.append(_k)
    s.append(_s)
p = list(map(int, input().split()))

def get_bits_pattern(n):
    bits_pattern = []
    for i in range(2**n):
        bits = [False]*n

        for j in range(n):
            if i >> j & 1:
                bits[j] = True
        bits_pattern.append(bits)
    return bits_pattern

bits_pattern = get_bits_pattern(n)

pattern_counter = 0
for bits in bits_pattern:
    is_on = True
    for _s, _p in zip(s, p):
        counter = 0
        for __s in _s:
            if bits[__s-1]:
                counter += 1
        if _p != counter % 2:
            is_on = False
    if is_on:
        pattern_counter += 1

print(pattern_counter) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m k = [] k [] s = [] s [] for _ in range(m):
    ks = list(map(int, input().split()))
    _k = ks[0]
    _s = [ks[i] for i in range(1, len(ks))]
    k.append(_k)
    s.append(_s) _ range(m) range m ks = list(map(int, input().split())) ks list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split _k = ks[0] _k ks[0] ks 0 ks[i] for i in range(1, len(ks)) for i in range(1, len(ks)) i range(1, len(ks)) range 1 len(ks) len ks for i in range(1, len(ks)) ks[i] ks i _s = [ks[i] for i in range(1, len(ks))] _s [ks[i] for i in range(1, len(ks))] k.append(_k) k.append k append _k s.append(_s) s.append s append _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 def get_bits_pattern(n):
    bits_pattern = []
    for i in range(2**n):
        bits = [False]*n

        for j in range(n):
            if i >> j & 1:
                bits[j] = True
        bits_pattern.append(bits)
    return bits_pattern get_bits_pattern bits_pattern = [] bits_pattern [] for i in range(2**n):
        bits = [False]*n

        for j in range(n):
            if i >> j & 1:
                bits[j] = True
        bits_pattern.append(bits)
     i range(2**n) range 2**n 2 n bits = [False]*n bits [False]*n [False] False n for j in range(n):
            if i >> j & 1:
                bits[j] = True
         j range(n) range n if i >> j & 1:
                bits[j] = True
         i >> j & 1 i >> j i j 1 bits[j] = True bits[j] bits j True bits_pattern.append(bits) bits_pattern.append bits_pattern append bits return bits_pattern bits_pattern n n bits_pattern = get_bits_pattern(n) bits_pattern get_bits_pattern(n) get_bits_pattern n pattern_counter = 0 pattern_counter 0 for bits in bits_pattern:
    is_on = True
    for _s, _p in zip(s, p):
        counter = 0
        for __s in _s:
            if bits[__s-1]:
                counter += 1
        if _p != counter % 2:
            is_on = False
    if is_on:
        pattern_counter += 1 bits bits_pattern is_on = True is_on True for _s, _p in zip(s, p):
        counter = 0
        for __s in _s:
            if bits[__s-1]:
                counter += 1
        if _p != counter % 2:
            is_on = False
     _s _p zip(s, p) zip s p counter = 0 counter 0 for __s in _s:
            if bits[__s-1]:
                counter += 1
         __s _s if bits[__s-1]:
                counter += 1
         bits[__s-1] bits __s-1 __s 1 counter += 1 counter 1 if _p != counter % 2:
            is_on = False
     _p != counter % 2 _p counter % 2 counter 2 is_on = False is_on False if is_on:
        pattern_counter += 1 is_on pattern_counter += 1 pattern_counter 1 print(pattern_counter) print pattern_counter pattern_counter = 0 0 pattern_counter bits_pattern = get_bits_pattern(n) get_bits_pattern(n) bits_pattern p = list(map(int, input().split())) list(map(int, input().split())) p k = [] [] k pattern_counter += 1 1 pattern_counter s = [] [] s _k = ks[0] ks[0] _k ks = list(map(int, input().split())) list(map(int, input().split())) ks counter += 1 1 counter counter = 0 0 counter is_on = False False is_on m = map(int, input().split()) map(int, input().split()) m is_on = True True is_on def get_bits_pattern(n):
    bits_pattern = []
    for i in range(2**n):
        bits = [False]*n

        for j in range(n):
            if i >> j & 1:
                bits[j] = True
        bits_pattern.append(bits)
    return bits_pattern def get_bits_pattern(n):
    bits_pattern = []
    for i in range(2**n):
        bits = [False]*n

        for j in range(n):
            if i >> j & 1:
                bits[j] = True
        bits_pattern.append(bits)
    return bits_pattern get_bits_pattern n, m = map(int, input().split()) map(int, input().split()) n _s = [ks[i] for i in range(1, len(ks))] [ks[i] for i in range(1, len(ks))] _s
n, m = map(int, input().split())
k = []
s = []
for _ in range(m):
    ks = list(map(int, input().split()))
    _k = ks[0]
    _s = [ks[i] for i in range(1, len(ks))]
    k.append(_k)
    s.append(_s)
p = list(map(int, input().split()))

def get_bits_pattern(n):
    bits_pattern = []
    for i in range(2**n):
        bits = [False]*n

        for j in range(n):
            if i >> j & 1:
                bits[j] = True
        bits_pattern.append(bits)
    return bits_pattern

bits_pattern = get_bits_pattern(n)

pattern_counter = 0
for bits in bits_pattern:
    is_on = True
    for _s, _p in zip(s, p):
        counter = 0
        for __s in _s:
            if bits[__s-1]:
                counter += 1
        if _p != counter % 2:
            is_on = False
    if is_on:
        pattern_counter += 1

print(pattern_counter)