from itertools import combinations, chain

n, m = list(map(int, input().split()))
ks = [list(map(int, input().split()))[1:] for i in range(m)]
ps = list(map(int, input().split()))

maxk = max(chain.from_iterable(ks))
cases = [format(i, '0{}b'.format(maxk)) for i in range(2 ** maxk)]


def count1(k, case):
    return len(list(filter(lambda s: s == '1', map(lambda i: case[i-1], k))))


if __name__ == '__main__':
    ans = []
    for case in cases:
        b = []
        for i, k in enumerate(ks):
            cnt = count1(k, case)
            if cnt % 2 == ps[i]:
                #print(case, k)
                b.append(True)
            else:
                b.append(False)
        # print(b)
        if all(b):
            ans.append(1)

    # print(ans)
    print(len(ans))
