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



S = []

for i in range(M):

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

    S.append(s)



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



count = 0

for i in range(2**N):

    switch = []

    for j in range(N):

        if ((i >> j) & 1):

            switch.append(j+1)

    #print(switch)

    c = 0

    for m in range(M):

        S_ = S[m]

        c_ = 0

        for s_ in range(1, S_[0]+1):

            if S_[s_] in switch:

                c_ += 1

        if c_ % 2 == P[m]:

            c += 1

    if c == M:

        count += 1



print(count)




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



s = []

for i in range(M):

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

    s.append(S[1:])



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



#print(s)



count = 0

for i in range(2**N):

    b = bin(i)[2:][::-1]

    switch = []

    for j in range(len(b)):

        if b[j] == "1":

            switch.append(j+1)

    #print(switch)

    

    f = 0

    for j in range(M):

        AND = len(list(set(switch) & set(s[j])))

        #print(AND, s[j])

        if (AND % 2 == p[j]):

            f += 1

    #print(f)

    if f == M:

        count += 1

    

                

    

    



print(count)
N, M = list(map(int, input().split()))
S = []
for i in range(M):
    s = list(map(int, input().split()))
    S.append(s)
P = list(map(int, input().split()))
count = 0
for i in range(2**N):
    switch = []
    for j in range(N):
        if (i >> j) & 1:
            switch.append(j + 1)
    # print(switch)
    c = 0
    for m in range(M):
        S_ = S[m]
        c_ = 0
        for s_ in range(1, S_[0] + 1):
            if S_[s_] in switch:
                c_ += 1
        if c_ % 2 == P[m]:
            c += 1
    if c == M:
        count += 1
print(count)

N, M = list(map(int, input().split()))
s = []
for i in range(M):
    S = list(map(int, input().split()))
    s.append(S[1:])
p = list(map(int, input().split()))
# print(s)
count = 0
for i in range(2**N):
    b = bin(i)[2:][::-1]
    switch = []
    for j in range(len(b)):
        if b[j] == "1":
            switch.append(j + 1)
    # print(switch)
    f = 0
    for j in range(M):
        AND = len(list(set(switch) & set(s[j])))
        # print(AND, s[j])
        if AND % 2 == p[j]:
            f += 1
    # print(f)
    if f == M:
        count += 1
print(count)

-S = [] +s = [] -    s = list(map(int, input().split())) -    S.append(s) -P = list(map(int, input().split())) +    S = list(map(int, input().split())) +    s.append(S[1:]) +p = list(map(int, input().split())) +# print(s) +    b = bin(i)[2:][::-1] -    for j in range(N): -        if (i >> j) & 1: +    for j in range(len(b)): +        if b[j] == "1": -    c = 0 -    for m in range(M): -        S_ = S[m] -        c_ = 0 -        for s_ in range(1, S_[0] + 1): -            if S_[s_] in switch: -                c_ += 1 -        if c_ % 2 == P[m]: -            c += 1 -    if c == M: +    f = 0 +    for j in range(M): +        AND = len(list(set(switch) & set(s[j]))) +        # print(AND, s[j]) +        if AND % 2 == p[j]: +            f += 1 +    # print(f) +    if f == M: