def LI(): return list(map(int, input().split()))


def convert(nums):
    return sum([2^(i-1) for i in nums])


def is_on(ons, bulb, p):
    return bin(ons & bulb).count('1') % 2 == p

def is_all_on(ons, bulbs, ps):
    res = True
    for bulb, p in zip(bulbs, ps):
        res &= is_on(ons, bulb, p)
    return res


n, m = LI()
k, s = [], []
for _ in range(m):
    _input = LI()
    k.append(_input[0])
    s.append(convert(_input[1:]))

p = LI()

res = 0
for ons in range(2**n):
    # print(ons, j, is_on(ons, s[j], p[j]))
    res += is_all_on(ons, s, p)

print(res)
