#ABC 128C

def main():

    import sys

    import itertools as ite

    N, M = list(map(int, sys.stdin.readline().split()))

    Light = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)]

    P = list(map(int, sys.stdin.readline().split()))

    S = list(ite.product([0,1], repeat=N)) #スイッチの状態

    ans = 0

    for s_state in S:

        L_result = [0 for _ in range(M)]

        for m in range(M):

            for s_no in Light[m][1:]:

                L_result[m] += s_state[s_no-1]

        L_result = list([x%2 for x in L_result])

        if P == L_result:

            ans +=1

    print(ans)



if __name__=='__main__':

    main()

#ABC128C

def main():

    import sys, itertools as ite

    N, M = list(map(int, sys.stdin.readline().split()))

    KS = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)]

    P = tuple(map(int, sys.stdin.readline().split()))

    

    #print(KS)

    #bit全探索

    SWS = tuple(ite.product([0,1], repeat=N)) 

    

    def judge(on_off):

        for i in range(M):

            on_cnt = 0

            for s in KS[i][1:]:

                on_cnt += on_off[s-1]

            if on_cnt %2 !=P[i]:

                return 0

        else:

            return 1

    ans = 0

    for on_off in SWS:

        ans +=judge(on_off)

    print(ans)













if __name__=='__main__':

    main()

# ABC 128C
def main():
    import sys
    import itertools as ite

    N, M = list(map(int, sys.stdin.readline().split()))
    Light = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)]
    P = list(map(int, sys.stdin.readline().split()))
    S = list(ite.product([0, 1], repeat=N))  # スイッチの状態
    ans = 0
    for s_state in S:
        L_result = [0 for _ in range(M)]
        for m in range(M):
            for s_no in Light[m][1:]:
                L_result[m] += s_state[s_no - 1]
        L_result = list([x % 2 for x in L_result])
        if P == L_result:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

# ABC128C
def main():
    import sys, itertools as ite

    N, M = list(map(int, sys.stdin.readline().split()))
    KS = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)]
    P = tuple(map(int, sys.stdin.readline().split()))
    # print(KS)
    # bit全探索
    SWS = tuple(ite.product([0, 1], repeat=N))

    def judge(on_off):
        for i in range(M):
            on_cnt = 0
            for s in KS[i][1:]:
                on_cnt += on_off[s - 1]
            if on_cnt % 2 != P[i]:
                return 0
        else:
            return 1

    ans = 0
    for on_off in SWS:
        ans += judge(on_off)
    print(ans)


if __name__ == "__main__":
    main()

-# ABC 128C +# ABC128C -    import sys -    import itertools as ite +    import sys, itertools as ite -    Light = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)] -    P = list(map(int, sys.stdin.readline().split())) -    S = list(ite.product([0, 1], repeat=N))  # スイッチの状態 +    KS = [tuple(map(int, sys.stdin.readline().split())) for _ in range(M)] +    P = tuple(map(int, sys.stdin.readline().split())) +    # print(KS) +    # bit全探索 +    SWS = tuple(ite.product([0, 1], repeat=N)) + +    def judge(on_off): +        for i in range(M): +            on_cnt = 0 +            for s in KS[i][1:]: +                on_cnt += on_off[s - 1] +            if on_cnt % 2 != P[i]: +                return 0 +        else: +            return 1 + -    for s_state in S: -        L_result = [0 for _ in range(M)] -        for m in range(M): -            for s_no in Light[m][1:]: -                L_result[m] += s_state[s_no - 1] -        L_result = list([x % 2 for x in L_result]) -        if P == L_result: -            ans += 1 +    for on_off in SWS: +        ans += judge(on_off)