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

switches = []

cnt = 0



for i in range(m):

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

    array.pop(0)

    switches.append(array)



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





def ch_binary(l, digit):

    num = [0] * digit

    for i in l:

        num[i-1] = 1

    return num



#スイッチのON、OFFをバイナリで表現する。

switches_2 = []

for i in switches:

    array = ch_binary(i, n)

    switches_2.append(array)







def check(a, b, digit, x):

    count = 0

    for i in range(digit):

        if a[i] == b[i] and b[i] == 1:

            count += 1

    if count % 2 == x:

        return 1

    else:

        return 0





for i in range(2**n):

    bin_str = list(map(int, format(i, 'b').zfill(n)))

    count = 0

    for j in range(m):

        y = check(switches_2[j], bin_str, n, p[j])

        count += y

    if count == m:

        cnt += 1



print(cnt)

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



switches = []



for i in range(m):

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

    switches.append(array[1:])



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



bit_size = 2 ** n



ans = 0



for i in range(bit_size):

    num = format(i, 'b').zfill(n)

    flag = True

    for j in range(m):

        a = 0

        for k in range(n):

            if num[k] == '1' and k+1 in switches[j]:

                a += 1

        if a % 2 == checker[j]:

            continue

        else:

            flag = False

            break

    if flag is True:

        ans += 1



print(ans)
n, m = list(map(int, input().split()))
switches = []
cnt = 0
for i in range(m):
    array = list(map(int, input().split()))
    array.pop(0)
    switches.append(array)
p = list(map(int, input().split()))


def ch_binary(l, digit):
    num = [0] * digit
    for i in l:
        num[i - 1] = 1
    return num


# スイッチのON、OFFをバイナリで表現する。
switches_2 = []
for i in switches:
    array = ch_binary(i, n)
    switches_2.append(array)


def check(a, b, digit, x):
    count = 0
    for i in range(digit):
        if a[i] == b[i] and b[i] == 1:
            count += 1
    if count % 2 == x:
        return 1
    else:
        return 0


for i in range(2**n):
    bin_str = list(map(int, format(i, "b").zfill(n)))
    count = 0
    for j in range(m):
        y = check(switches_2[j], bin_str, n, p[j])
        count += y
    if count == m:
        cnt += 1
print(cnt)

n, m = list(map(int, input().split()))
switches = []
for i in range(m):
    array = list(map(int, input().split()))
    switches.append(array[1:])
checker = list(map(int, input().split()))
bit_size = 2**n
ans = 0
for i in range(bit_size):
    num = format(i, "b").zfill(n)
    flag = True
    for j in range(m):
        a = 0
        for k in range(n):
            if num[k] == "1" and k + 1 in switches[j]:
                a += 1
        if a % 2 == checker[j]:
            continue
        else:
            flag = False
            break
    if flag is True:
        ans += 1
print(ans)

-cnt = 0 -    array.pop(0) -    switches.append(array) -p = list(map(int, input().split())) - - -def ch_binary(l, digit): -    num = [0] * digit -    for i in l: -        num[i - 1] = 1 -    return num - - -# スイッチのON、OFFをバイナリで表現する。 -switches_2 = [] -for i in switches: -    array = ch_binary(i, n) -    switches_2.append(array) - - -def check(a, b, digit, x): -    count = 0 -    for i in range(digit): -        if a[i] == b[i] and b[i] == 1: -            count += 1 -    if count % 2 == x: -        return 1 -    else: -        return 0 - - -for i in range(2**n): -    bin_str = list(map(int, format(i, "b").zfill(n))) -    count = 0 +    switches.append(array[1:]) +checker = list(map(int, input().split())) +bit_size = 2**n +ans = 0 +for i in range(bit_size): +    num = format(i, "b").zfill(n) +    flag = True -        y = check(switches_2[j], bin_str, n, p[j]) -        count += y -    if count == m: -        cnt += 1 -print(cnt) +        a = 0 +        for k in range(n): +            if num[k] == "1" and k + 1 in switches[j]: +                a += 1 +        if a % 2 == checker[j]: +            continue +        else: +            flag = False +            break +    if flag is True: +        ans += 1 +print(ans)