n, m = map(int, input().split())
S = []
for _ in range(m):
    k, *s = [int(x) for x in input().split()]
    s = list(map(lambda x: x - 1, s))  # 0-indexed
    S.append(s)

P = list(map(int, input().split()))
ans = 0

for i in range(2 ** n):
    now_s = []
    flag = True
    for j in range(n):
        if (i >> j & 1):
            now_s.append(1)
        else:
            now_s.append(0)
    tmp = 0
    for k in range(m):
        s = S[k]
        for x in s:
            if now_s[x] == 1:
                tmp += now_s[x]
        if tmp % 2 != P[k]:
            flag = False
    if flag:
        ans += 1

print(ans)
