def main():
    N,M=map(int,input().split())
    s=[[] for i in range(0,M)]
    for i in range(0,M):
        s[i]+=list(map(int,input().split()))
    p=list(map(int,input().split()))
    ans=0
    for i in range(0,2**N):
        x=0
        flag=0
        for j in range(0,M):
            for k in range(1,s[j][0]+1):
                x+=(i >> (s[j][k]-1) & 1)
            if x%2!=p[j]:
                flag=1
        if flag==0:
            ans=ans+1
    print(ans)

if __name__ == '__main__':
    main()
