n, m = map(int, input().split())
s = []

for i in range(m):
    temp = list(map(int, input().split()))
    s.append(temp[1:])

p = list(map(int, input().split()))

# print(s)

def isAllOn(n):
    # print('\nn:', n)
    for i in range(m):
        # print('Light:', i)
        bitCnt = 0
        for j in range(len(s[i])):
            pos = s[i][j] - 1
            # print('pos:', pos)
            bit = (n >> pos) & 1
            if bit == 1:
                bitCnt += 1
        if bitCnt % 2 != p[i]:
            # print('False!')
            return False

    return True

ans = 0

for i in range(2**n+1):
    if isAllOn(i):
        ans += 1

print(ans)