n, m = (int(i) for i in raw_input().split())
switches = []
for i in range(m):
    line = [int(i) for i in raw_input().split()]
    switches.append(line[1:])

ps = [int(i) for i in raw_input().split()]

ans = 0
for i in range(2 ** n):
    pattern = []
    for d in range(n):
        if (1 << d) & i:
            pattern.append(True)
        else:
            pattern.append(False)

    ok = True
    for j in range(m):
        count = 0
        for p in pattern[switches[j][0]-1:switches[j][-1]]:
            if p:
                count += 1
        ok = ok and (count % 2 == ps[j])
    if ok:
        ans += 1
print ans
