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

k = [0] * M

s = [0] * M

for i in range(M):

  l = [int(j) for j in input().split()]

  k[i], s[i] = l[0], l[1:]

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



res = 0

for bit in range(2**N):

  sw = [0] * N

  for i in range(N):

    sw[i] = (bit >> i) & 1

  are_shining = True

  for i in range(M):

    cnt_on = 0

    for j in range(k[i]):

      if sw[s[i][j]-1] == 1:

        cnt_on += 1

    if cnt_on % 2 != p[i]:

      are_shining = False

  if are_shining:

    res += 1



print(res)

import sys



input = sys.stdin.readline





def main():

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

    k = [None] * M

    s = [None] * M

    for i in range(M):

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

        k[i], s[i] = line[0], line[1:]

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



    ans = 0

    for bit in range(2 ** N):

        light_all = True

        # on/off on switches

        sw = [None] * N

        for i in range(N):

            if bit & (1 << i):

                sw[i] = True

            else:

                sw[i] = False

        for i in range(M):

            n_on = 0

            for j in s[i]:

                n_on += sw[j - 1]

            if n_on % 2 == p[i]:

                pass

            else:

                light_all = False

        ans += light_all



    print(ans)





if __name__ == "__main__":

    main()

N, M = list(map(int, input().split()))
k = [0] * M
s = [0] * M
for i in range(M):
    l = [int(j) for j in input().split()]
    k[i], s[i] = l[0], l[1:]
p = [int(i) for i in input().split()]
res = 0
for bit in range(2**N):
    sw = [0] * N
    for i in range(N):
        sw[i] = (bit >> i) & 1
    are_shining = True
    for i in range(M):
        cnt_on = 0
        for j in range(k[i]):
            if sw[s[i][j] - 1] == 1:
                cnt_on += 1
        if cnt_on % 2 != p[i]:
            are_shining = False
    if are_shining:
        res += 1
print(res)

import sys

input = sys.stdin.readline


def main():
    N, M = list(map(int, input().split()))
    k = [None] * M
    s = [None] * M
    for i in range(M):
        line = tuple(map(int, input().split()))
        k[i], s[i] = line[0], line[1:]
    p = tuple(map(int, input().split()))
    ans = 0
    for bit in range(2**N):
        light_all = True
        # on/off on switches
        sw = [None] * N
        for i in range(N):
            if bit & (1 << i):
                sw[i] = True
            else:
                sw[i] = False
        for i in range(M):
            n_on = 0
            for j in s[i]:
                n_on += sw[j - 1]
            if n_on % 2 == p[i]:
                pass
            else:
                light_all = False
        ans += light_all
    print(ans)


if __name__ == "__main__":
    main()

-N, M = list(map(int, input().split())) -k = [0] * M -s = [0] * M -for i in range(M): -    l = [int(j) for j in input().split()] -    k[i], s[i] = l[0], l[1:] -p = [int(i) for i in input().split()] -res = 0 -for bit in range(2**N): -    sw = [0] * N -    for i in range(N): -        sw[i] = (bit >> i) & 1 -    are_shining = True +import sys + +input = sys.stdin.readline + + +def main(): +    N, M = list(map(int, input().split())) +    k = [None] * M +    s = [None] * M -        cnt_on = 0 -        for j in range(k[i]): -            if sw[s[i][j] - 1] == 1: -                cnt_on += 1 -        if cnt_on % 2 != p[i]: -            are_shining = False -    if are_shining: -        res += 1 -print(res) +        line = tuple(map(int, input().split())) +        k[i], s[i] = line[0], line[1:] +    p = tuple(map(int, input().split())) +    ans = 0 +    for bit in range(2**N): +        light_all = True +        # on/off on switches +        sw = [None] * N +        for i in range(N): +            if bit & (1 << i): +                sw[i] = True +            else: +                sw[i] = False +        for i in range(M): +            n_on = 0 +            for j in s[i]: +                n_on += sw[j - 1] +            if n_on % 2 == p[i]: +                pass +            else: +                light_all = False +        ans += light_all +    print(ans) + + +if __name__ == "__main__": +    main()