#!/usr/bin/env python3

MOD = 2  # type: int


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    # Failed to predict input format
    N,M = map(int,input().split())
    from collections import defaultdict
    d = defaultdict()
    for i in range(M):
        l = list(map(int,input().split()))
        d[i] = l[1:]

    # for k,v in d.items():
    #     print(k,v)

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

    ans = 0
    import itertools
    s = ('on', 'off')
    for i in itertools.product(s, repeat=N):
        anst = 0
        for k,v in d.items():
            if(len([x for x in v if(i[x-1] == 'on')])%2 == p[k-1]):
                anst += 1

        if(anst == M):
            ans += 1
    
    print(ans)



if __name__ == '__main__':
    main()
