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

ans = 0
for i in range(1 << n):
    v = [1 - i for i in p]
    for j in range(m):
        if (i & (1 << j)):
            for t in s[j]:
                v[t - 1] = 1 - v[t - 1]
    if sum(v) == m:
        ans += 1
    #print(i, v)
print(ans)
