def main():

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

  g = [[-1]*n for _ in range(m)]

  for i in range(m):

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

    for j in s[1:]:

      g[i][j-1] = 1

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



  ans = 0

  for i in range(2**n):

    s = [0]*n

    for j in range(n):

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

        s[j] = 1

    

    flag = True

    for j in range(m):

      cnt = 0

      for k in range(n):

        if g[j][k] == s[k]:

          cnt += 1

      if cnt % 2 != p[j]:

        flag = False

    if flag:

      ans += 1

  

  print(ans) 



if __name__ == '__main__':

  main()
def main():

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

  light = [[0]*n for _ in range(m)]

  for i in range(m):

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

    k = kk.pop(0)

    for j in range(k):

      light[i][kk[j]-1] = 1

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



  ans = 0

  for i in range(2**n): # switchのbit

    sw = [0]*n

    for j in range(n):

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

        sw[j] = 1



    flag = True

    for j in range(m):

      cnt = 0

      for k in range(n):

        if sw[k] == 1 and light[j][k] == 1:

          cnt += 1

      if cnt % 2 != p[j]:

        flag = False

        break

    if flag:

      ans += 1

    

  print(ans)



if __name__ == '__main__':

  main()
def main():
    n, m = list(map(int, input().split()))
    g = [[-1] * n for _ in range(m)]
    for i in range(m):
        s = list(map(int, input().split()))
        for j in s[1:]:
            g[i][j - 1] = 1
    p = list(map(int, input().split()))
    ans = 0
    for i in range(2**n):
        s = [0] * n
        for j in range(n):
            if (i >> j) & 1:
                s[j] = 1
        flag = True
        for j in range(m):
            cnt = 0
            for k in range(n):
                if g[j][k] == s[k]:
                    cnt += 1
            if cnt % 2 != p[j]:
                flag = False
        if flag:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

def main():
    n, m = list(map(int, input().split()))
    light = [[0] * n for _ in range(m)]
    for i in range(m):
        kk = list(map(int, input().split()))
        k = kk.pop(0)
        for j in range(k):
            light[i][kk[j] - 1] = 1
    p = list(map(int, input().split()))
    ans = 0
    for i in range(2**n):  # switchのbit
        sw = [0] * n
        for j in range(n):
            if (i >> j) & 1:
                sw[j] = 1
        flag = True
        for j in range(m):
            cnt = 0
            for k in range(n):
                if sw[k] == 1 and light[j][k] == 1:
                    cnt += 1
            if cnt % 2 != p[j]:
                flag = False
                break
        if flag:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-    g = [[-1] * n for _ in range(m)] +    light = [[0] * n for _ in range(m)] -        s = list(map(int, input().split())) -        for j in s[1:]: -            g[i][j - 1] = 1 +        kk = list(map(int, input().split())) +        k = kk.pop(0) +        for j in range(k): +            light[i][kk[j] - 1] = 1 -    for i in range(2**n): -        s = [0] * n +    for i in range(2**n):  # switchのbit +        sw = [0] * n -                s[j] = 1 +                sw[j] = 1 -                if g[j][k] == s[k]: +                if sw[k] == 1 and light[j][k] == 1: +                break