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

k = [0] * M

s = [0] * M

for i in range(M):

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

    for j,x in enumerate(ks):

        if j == 0:

            k[i] = x

            continue

        s[i] += 1 << x-1

p = [int(i) for i in input().split()]



answer = 0

for i in range(2**N):

    count = [0] * M

    for j in range(M):

        tmp = s[j] & i

        while tmp:

            if tmp & 1:

                count[j] += 1

            tmp >>= 1



        # j番目の電球が光る場合 count[j] = 1

        if count[j] % 2 == p[j]:

            count[j] = 1

        else:

            count[j] = 0



    # 全ての電球が点灯する場合

    if not 0 in count:

        answer += 1



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

S = []

for _ in range(M):

    INPUT = tuple(map(int,input().split()))

    S.append(INPUT[1:])

P = [int(i) for i in input().split()]



ans = 0

for i in range(2**N):

    # state[i]: スイッチiがon

    state = [False] * N

    for j in range(N):

        if 1 & (i >> j):

            state[j] = True

    

    # 全ての電球が点灯するか判定

    flag = True

    for j in range(M):

        cnt = 0

        for s in S[j]:

            if state[s-1]:

                cnt += 1

        if cnt % 2 != P[j]:

            flag = False

    

    if flag:

        ans += 1



print(ans)
N, M = list(map(int, input().split()))
k = [0] * M
s = [0] * M
for i in range(M):
    ks = list(map(int, input().split()))
    for j, x in enumerate(ks):
        if j == 0:
            k[i] = x
            continue
        s[i] += 1 << x - 1
p = [int(i) for i in input().split()]
answer = 0
for i in range(2**N):
    count = [0] * M
    for j in range(M):
        tmp = s[j] & i
        while tmp:
            if tmp & 1:
                count[j] += 1
            tmp >>= 1
        # j番目の電球が光る場合 count[j] = 1
        if count[j] % 2 == p[j]:
            count[j] = 1
        else:
            count[j] = 0
    # 全ての電球が点灯する場合
    if not 0 in count:
        answer += 1
print(answer)

N, M = list(map(int, input().split()))
S = []
for _ in range(M):
    INPUT = tuple(map(int, input().split()))
    S.append(INPUT[1:])
P = [int(i) for i in input().split()]
ans = 0
for i in range(2**N):
    # state[i]: スイッチiがon
    state = [False] * N
    for j in range(N):
        if 1 & (i >> j):
            state[j] = True
    # 全ての電球が点灯するか判定
    flag = True
    for j in range(M):
        cnt = 0
        for s in S[j]:
            if state[s - 1]:
                cnt += 1
        if cnt % 2 != P[j]:
            flag = False
    if flag:
        ans += 1
print(ans)

-k = [0] * M -s = [0] * M -for i in range(M): -    ks = list(map(int, input().split())) -    for j, x in enumerate(ks): -        if j == 0: -            k[i] = x -            continue -        s[i] += 1 << x - 1 -p = [int(i) for i in input().split()] -answer = 0 +S = [] +for _ in range(M): +    INPUT = tuple(map(int, input().split())) +    S.append(INPUT[1:]) +P = [int(i) for i in input().split()] +ans = 0 -    count = [0] * M +    # state[i]: スイッチiがon +    state = [False] * N +    for j in range(N): +        if 1 & (i >> j): +            state[j] = True +    # 全ての電球が点灯するか判定 +    flag = True -        tmp = s[j] & i -        while tmp: -            if tmp & 1: -                count[j] += 1 -            tmp >>= 1 -        # j番目の電球が光る場合 count[j] = 1 -        if count[j] % 2 == p[j]: -            count[j] = 1 -        else: -            count[j] = 0 -    # 全ての電球が点灯する場合 -    if not 0 in count: -        answer += 1 -print(answer) +        cnt = 0 +        for s in S[j]: +            if state[s - 1]: +                cnt += 1 +        if cnt % 2 != P[j]: +            flag = False +    if flag: +        ans += 1 +print(ans)