# import itertools

n, m = list(map(int, input().split()))

s = []

for i in range(m):

    s.append(list(map(int, input().split())))

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

ans = 0



for i in range(2**n):

    b = list(str(bin(i))[2:].zfill(n))

    # print(b)

    ok = True

    for j in range(m):

        Sum = 0

        for k in range(s[j][0]):

            Sum += int(b[s[j][k+1] - 1])

        # print(i, j, Sum)

        if Sum % 2 != p[j]:

            ok = False

    if ok:

        ans += 1

print(ans)        

# print(s, p)
N, M = list(map(int, input().split()))

s = []

k = []

for _ in range(M):

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

    k.append(x.pop(0))

    s.append(x)

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

# print(s, k, p)

ans = 0

for i in range(2**N):

    Switches = [0]*N

    for j in range(N):

        if (i >> j) & 1:

            Switches[j] = 1

    # print(Switches)

    Lamps = [0]*M

    for j in range(M):

        for l in range(k[j]):

            if Switches[s[j][l] - 1] == 1:

                Lamps[j] += 1



    # print(Lamps)

    ok = True

    for j in range(M):

        # if Lamps[j] == 0:

        #     ok = False

        #     break

        if Lamps[j] % 2 != p[j]:

            ok = False

            break



    if ok:

        ans += 1

    

print(ans)



# import itertools
n, m = list(map(int, input().split()))
s = []
for i in range(m):
    s.append(list(map(int, input().split())))
p = list(map(int, input().split()))
ans = 0
for i in range(2**n):
    b = list(str(bin(i))[2:].zfill(n))
    # print(b)
    ok = True
    for j in range(m):
        Sum = 0
        for k in range(s[j][0]):
            Sum += int(b[s[j][k + 1] - 1])
        # print(i, j, Sum)
        if Sum % 2 != p[j]:
            ok = False
    if ok:
        ans += 1
print(ans)
# print(s, p)

N, M = list(map(int, input().split()))
s = []
k = []
for _ in range(M):
    x = list(map(int, input().split()))
    k.append(x.pop(0))
    s.append(x)
p = list(map(int, input().split()))
# print(s, k, p)
ans = 0
for i in range(2**N):
    Switches = [0] * N
    for j in range(N):
        if (i >> j) & 1:
            Switches[j] = 1
    # print(Switches)
    Lamps = [0] * M
    for j in range(M):
        for l in range(k[j]):
            if Switches[s[j][l] - 1] == 1:
                Lamps[j] += 1
    # print(Lamps)
    ok = True
    for j in range(M):
        # if Lamps[j] == 0:
        #     ok = False
        #     break
        if Lamps[j] % 2 != p[j]:
            ok = False
            break
    if ok:
        ans += 1
print(ans)

-# import itertools -n, m = list(map(int, input().split())) +N, M = list(map(int, input().split())) -for i in range(m): -    s.append(list(map(int, input().split()))) +k = [] +for _ in range(M): +    x = list(map(int, input().split())) +    k.append(x.pop(0)) +    s.append(x) +# print(s, k, p) -for i in range(2**n): -    b = list(str(bin(i))[2:].zfill(n)) -    # print(b) +for i in range(2**N): +    Switches = [0] * N +    for j in range(N): +        if (i >> j) & 1: +            Switches[j] = 1 +    # print(Switches) +    Lamps = [0] * M +    for j in range(M): +        for l in range(k[j]): +            if Switches[s[j][l] - 1] == 1: +                Lamps[j] += 1 +    # print(Lamps) -    for j in range(m): -        Sum = 0 -        for k in range(s[j][0]): -            Sum += int(b[s[j][k + 1] - 1]) -        # print(i, j, Sum) -        if Sum % 2 != p[j]: +    for j in range(M): +        # if Lamps[j] == 0: +        #     ok = False +        #     break +        if Lamps[j] % 2 != p[j]: +            break -# print(s, p)