N, M = map(int, input().split(" "))
botlist = []
ans = 0
for n in range(M):
    bot = list(map(int, input().split(" ")))
    
    botlist.append(bot)
#botlist
plist = list(map(int, input().split(" ")))

pushlist = [[]for i in range(2**N)]

for p in range(N):
    M = (2**N)/(p+1)
    for q in range(M):
        for r in range(p+1):
            if q%2 == 0:
                pushlist[r*q] = 0
            else:
                pushlist[r*q] = 1

for A in pushlist:
    g = 0
    for B in botlist:
        cou = 0
        for c in range(B[0]):
            cou += A[B[c]]
        if cou % 2 == plist[g]:
            ans += 1
    g +=1

print(ans)


    



