def Switches():
    from math import log2
    N, M = map(int, input().split())
    # m行n列
    switchList = []

    # スイッチの組み合わせ取得
    for i in range(M):
        k = list(map(int, input().split()))
        k = k[1:]
        # print(k)
        switchList.append([True * (i+1 in k) for i in range(N)])
    p = list(map(int, input().split()))
    # print(switchList)
    result = 0

    # 2bit化し、条件比較を行い結果がpと等しければ正解とする
    for i in range(2**N):
        tmp = format(i, "0"+str(N)+"b")
        tmp = [int(j) for j in tmp]
        # print(tmp)
        tmp = [sum([switchList[k][j] * tmp[j] for j in range(N)]) % 2 for k in range(M)]
        if p == tmp:
            result += 1

    print(result)

if __name__ == "__main__":
    Switches()