def main():
    import itertools
    n,m = map(int,input().split())
    lit = []
    for i in range(m):
        lit.append(list(map(int,input().split())))
    p = list(map(int,input().split()))
    stats = ((0,1) for i in range(n))
    ans = 0
    for stat in itertools.product(*stats):
        s = 0
        flg = 0
        for i in range(m):
            for j in range(lit[i][0]):
                s += stat[lit[i][j+1]-1]
            if s%2==p[i]:
                continue
            else:
                flg = 1
                break
        if flg==0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()
