n,m = map(int,input().split())
s = []
for i in range(m):
    s.append(list(map(int,input().split())))
    
p = list(map(int,input().split()))
ans = 0
for i1 in range(2):
    for i2 in range(2):
        for i3 in range(2):
            for i4 in range(2):
                for i5 in range(2):
                    for i6 in range(2):
                        for i7 in range(2):
                            for i8 in range(2):
                                for i9 in range(2):
                                    for i10 in range(2):
                                        switches = [i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                                        flag_temp = 0
                                        for i in range(m):
                                            temp = 0
                                            for l in range(s[i][0]):
                                                temp += switches[s[i][l+1]-1]
                                            if temp % 2 == p[i]:
                                                flag = 1
                                                flag_temp += 1
                                        if flag == 1 and flag_temp == m:
                                            ans += 1

print(int(ans/2**(10-n)))