def main():
    N, M = (int(i) for i in input().split())
    s = [[int(i) for i in input()[2:].split()] for j in range(M)]
    p = [int(i) for i in input().split()]
    ans = 0
    for bit in range(1<<N):
        switches = [0] * N
        for i in range(N):
            if bit & (1<<i):
                switches[i] = 1
        for ss,pp in zip(s,p):
            tmp = 0
            for i in ss:
                if switches[i-1]:
                    tmp += 1
            if tmp%2 != pp:
                break
        else:
            print(switches)
            ans += 1
    print(ans)
if __name__ == '__main__':
    main()