
from itertools import combinations
def main():
    n, m = map(int, input().split())
    cs = []
    for _ in range(m):
        tmpl = list(map(int, input().split()))
        tmpl.pop(0)
        cs.append(set(tmpl))
    p = list(map(int, input().split()))

    r = 0
    switch_patterns = []
    switches = [i for i in range(1, n+1)]
    for i1 in range(1,n+1):
        switch_patterns += combinations(switches, i1)
    switch_patterns_set = []
    for pattern in switch_patterns:
        switch_patterns_set.append(set(pattern))

    for pattern in switch_patterns_set:
        check = []
        for i2 in range(m):
            check.append(len(pattern.intersection(cs[i2])) % 2 == p[i2])
        r += all(check)
    print(r)

if __name__ == '__main__':
    main()
