
def main():
    nn, m = map(int, raw_input().split())
    ss = []
    for _ in xrange(m):
        n = 0
        for s in map(int, raw_input().split()[1:]):
            n |= 1 << (s - 1)
        ss.append(n)
    pp = map(int, raw_input().split())
    ans = 0
    for sw in xrange(2 ** nn):
        for s, p in zip(ss, pp):
            if bin((sw & s)).count('1') % 2 != p:
                break
        else:
            ans += 1
    print ans


if __name__ == '__main__':
    main()
