n,m = map(int,input().split())
k = list()
for i in range(m):
    k.append(map(int,input().split()))
p = list(map(int,input().split()))
s = [0 for i in range(n)]
ans = 0
def switch(num):
    global count,ans,s,k
    for i in [0,1]:
        if num == n:
            count = 0
            flag = True
        if num != 1:
            s[n-num] = i
            switch(num-1)
        else:
            s[n-num] = i
            for j in range(m):
                print(k)
                print(k[j])
                u = list(k[j]) #電球jのスイッチについて考える
                for k in range(1,len(u)):
                    count += s[u[k]-1]
                if count % 2 != p[j]:
                    flag = False
            if flag:
                ans += 1
switch(n)
print(ans)