N, M = list(map(int, input().split()))

connected = [list(map(int,input().split())) for _ in range(M)]

condition = list(map(int, input().split()))

ans = 0



for i in range(1<<N):

    count1 = 0

    for j,lst in enumerate(connected):

        count2 = 0

        for s in lst[1:]:

            if (i>>(s-1)) & 1:

                count2 += 1

        if count2 % 2 == condition[j]:

            count1 += 1

    if count1 == M:

        ans += 1



print(ans)
N, M = list(map(int, input().split()))

connected = [list(map(int,input().split())) for _ in range(M)]

condition = list(map(int, input().split()))

ans = 0



for i in range(1<<N):

    FLG = True

    for j,lst in enumerate(connected):

        count2 = 0

        for s in lst[1:]:

            if (i>>(s-1)) & 1:

                count2 += 1

        if count2 % 2 != condition[j]:

            FLG = False

            break

    if FLG:

        ans += 1



print(ans)
N, M = list(map(int, input().split()))
connected = [list(map(int, input().split())) for _ in range(M)]
condition = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
    count1 = 0
    for j, lst in enumerate(connected):
        count2 = 0
        for s in lst[1:]:
            if (i >> (s - 1)) & 1:
                count2 += 1
        if count2 % 2 == condition[j]:
            count1 += 1
    if count1 == M:
        ans += 1
print(ans)

N, M = list(map(int, input().split()))
connected = [list(map(int, input().split())) for _ in range(M)]
condition = list(map(int, input().split()))
ans = 0
for i in range(1 << N):
    FLG = True
    for j, lst in enumerate(connected):
        count2 = 0
        for s in lst[1:]:
            if (i >> (s - 1)) & 1:
                count2 += 1
        if count2 % 2 != condition[j]:
            FLG = False
            break
    if FLG:
        ans += 1
print(ans)

-    count1 = 0 +    FLG = True -        if count2 % 2 == condition[j]: -            count1 += 1 -    if count1 == M: +        if count2 % 2 != condition[j]: +            FLG = False +            break +    if FLG: