import sys

readline=sys.stdin.readline

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

mlst = [0] * M

for i in range(1,M+1):

  _, *tmp = list(map(int,readline().split()))

  for j in tmp:

    mlst[i-1] |= 1<<(j-1)

    

def popcnt(n):

    # 求1的个数

    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)

    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)

    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)

    c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)

    c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)

    c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff)

    return c

  

  

mod = list(map(int, readline().split()))

ab = list(zip(mlst, mod))

res = 0

for i in range(1<<N):

  for a,b in ab:

    tmp = a & i

    if popcnt(tmp) & 1 != b:

      break

  else:

    res += 1

print(res)
import sys

readline=sys.stdin.readline

def main():

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

  mlst = [0] * M

  for i in range(1,M+1):

    _, *tmp = list(map(int,readline().split()))

    for j in tmp:

      mlst[i-1] |= 1<<(j-1)



  def popcnt(n):

      # 求1的个数

      c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)

      c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)

      c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)

      c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)

      c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)

      return c





  mod = list(map(int, readline().split()))

  ab = list(zip(mlst, mod))

  res = 0

  for i in range(1<<N):

    for a,b in ab:

      tmp = a & i

      if popcnt(tmp) & 1 != b:

        break

    else:

      res += 1

  print(res)

if __name__ == '__main__':

  main()
import sys

readline = sys.stdin.readline
N, M = list(map(int, readline().split()))
mlst = [0] * M
for i in range(1, M + 1):
    _, *tmp = list(map(int, readline().split()))
    for j in tmp:
        mlst[i - 1] |= 1 << (j - 1)


def popcnt(n):
    # 求1的个数
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
    c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F)
    c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF)
    c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF)
    c = (c & 0x00000000FFFFFFFF) + ((c >> 32) & 0x00000000FFFFFFFF)
    return c


mod = list(map(int, readline().split()))
ab = list(zip(mlst, mod))
res = 0
for i in range(1 << N):
    for a, b in ab:
        tmp = a & i
        if popcnt(tmp) & 1 != b:
            break
    else:
        res += 1
print(res)

import sys

readline = sys.stdin.readline


def main():
    N, M = list(map(int, readline().split()))
    mlst = [0] * M
    for i in range(1, M + 1):
        _, *tmp = list(map(int, readline().split()))
        for j in tmp:
            mlst[i - 1] |= 1 << (j - 1)

    def popcnt(n):
        # 求1的个数
        c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
        c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
        c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F)
        c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF)
        c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF)
        return c

    mod = list(map(int, readline().split()))
    ab = list(zip(mlst, mod))
    res = 0
    for i in range(1 << N):
        for a, b in ab:
            tmp = a & i
            if popcnt(tmp) & 1 != b:
                break
        else:
            res += 1
    print(res)


if __name__ == "__main__":
    main()

-N, M = list(map(int, readline().split())) -mlst = [0] * M -for i in range(1, M + 1): -    _, *tmp = list(map(int, readline().split())) -    for j in tmp: -        mlst[i - 1] |= 1 << (j - 1) -def popcnt(n): -    # 求1的个数 -    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555) -    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333) -    c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F) -    c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF) -    c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF) -    c = (c & 0x00000000FFFFFFFF) + ((c >> 32) & 0x00000000FFFFFFFF) -    return c +def main(): +    N, M = list(map(int, readline().split())) +    mlst = [0] * M +    for i in range(1, M + 1): +        _, *tmp = list(map(int, readline().split())) +        for j in tmp: +            mlst[i - 1] |= 1 << (j - 1) + +    def popcnt(n): +        # 求1的个数 +        c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555) +        c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333) +        c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F) +        c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF) +        c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF) +        return c + +    mod = list(map(int, readline().split())) +    ab = list(zip(mlst, mod)) +    res = 0 +    for i in range(1 << N): +        for a, b in ab: +            tmp = a & i +            if popcnt(tmp) & 1 != b: +                break +        else: +            res += 1 +    print(res) -mod = list(map(int, readline().split())) -ab = list(zip(mlst, mod)) -res = 0 -for i in range(1 << N): -    for a, b in ab: -        tmp = a & i -        if popcnt(tmp) & 1 != b: -            break -    else: -        res += 1 -print(res) +if __name__ == "__main__": +    main()