n,m = list(map(int, input().split()))
k = [list(map(int, input().split()))[1:] for i in range(m)]
p = list(map(int, input().split()))

ans=0
for i in range(2**n):
    # 1,2,3...,Nのスイッチの状態
    state=[(i>>j)&1 for j in range(n)]
#    print('state=',state)
    on_cnt=0
    ok=1
    for ii, x in enumerate(k):
#        print('x=',x)
        for y in x:
            if state[y-1]==1:
                on_cnt+=1
        if on_cnt%2!=p[ii]:
            ok=0
            break
    if ok==1:
        ans+=1

print(ans)