#ABC 128C

def main():

    import sys

    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()))

    #print(Light)

    #print(P)

    ans = 0

    for i in range(2**N):

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

        for m in range(M):

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

                cnt[m] += (i>>N-s)&1

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

        if cnt == P:

            ans +=1

    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()

# ABC 128C
def main():
    import sys

    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()))
    # print(Light)
    # print(P)
    ans = 0
    for i in range(2**N):
        cnt = [0 for _ in range(M)]
        for m in range(M):
            for s in Light[m][1:]:
                cnt[m] += (i >> N - s) & 1
        cnt = list([x % 2 for x in cnt])
        if cnt == P:
            ans += 1
    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()

+    import itertools as ite -    # print(Light) -    # print(P) +    S = list(ite.product([0, 1], repeat=N))  # スイッチの状態 -    for i in range(2**N): -        cnt = [0 for _ in range(M)] +    for s_state in S: +        L_result = [0 for _ in range(M)] -            for s in Light[m][1:]: -                cnt[m] += (i >> N - s) & 1 -        cnt = list([x % 2 for x in cnt]) -        if cnt == P: +            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: