import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from itertools import product
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, M = map(int, readline().split())
    S = []
    for _ in range(M):
        k, *s = map(int, readline().split())
        S.append(s)
    P = list(map(int, readline().split()))
    ans = 0

    for switch in product((0,1),repeat=N):
        for i, s in enumerate(S):
            tmp = 0
            for k in s:
                tmp ^= switch[k-1]
            if tmp==P[i]:
                continue
            else:
                break
        else:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()
 import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline from itertools import product sys.setrecursionlimit(10 ** 8) sys.setrecursionlimit sys setrecursionlimit 10 ** 8 10 8 INF = float('inf') INF float('inf') float 'inf' MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 def main():
    N, M = map(int, readline().split())
    S = []
    for _ in range(M):
        k, *s = map(int, readline().split())
        S.append(s)
    P = list(map(int, readline().split()))
    ans = 0

    for switch in product((0,1),repeat=N):
        for i, s in enumerate(S):
            tmp = 0
            for k in s:
                tmp ^= switch[k-1]
            if tmp==P[i]:
                continue
            else:
                break
        else:
            ans += 1

    print(ans) main N, M = map(int, readline().split()) N map(int, readline().split()) map int readline().split() ().split () readline split M S = [] S [] for _ in range(M):
        k, *s = map(int, readline().split())
        S.append(s)
     _ range(M) range M k, *s = map(int, readline().split()) k map(int, readline().split()) map int readline().split() ().split () readline split *s s S.append(s) S.append S append s P = list(map(int, readline().split())) P list(map(int, readline().split())) list map(int, readline().split()) map int readline().split() ().split () readline split ans = 0 ans 0 for switch in product((0,1),repeat=N):
        for i, s in enumerate(S):
            tmp = 0
            for k in s:
                tmp ^= switch[k-1]
            if tmp==P[i]:
                continue
            else:
                break
        else:
            ans += 1

     switch product((0,1),repeat=N) product (0,1) 0 1 repeat=N repeat N for i, s in enumerate(S):
            tmp = 0
            for k in s:
                tmp ^= switch[k-1]
            if tmp==P[i]:
                continue
            else:
                break
        else:
            ans += 1

     i s enumerate(S) enumerate S tmp = 0 tmp 0 for k in s:
                tmp ^= switch[k-1]
             k s tmp ^= switch[k-1] tmp switch[k-1] switch k-1 k 1 if tmp==P[i]:
                continue
            else:
                break
         tmp==P[i] tmp P[i] P i continue break ans += 1 ans 1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main read = sys.stdin.read sys.stdin.read read def main():
    N, M = map(int, readline().split())
    S = []
    for _ in range(M):
        k, *s = map(int, readline().split())
        S.append(s)
    P = list(map(int, readline().split()))
    ans = 0

    for switch in product((0,1),repeat=N):
        for i, s in enumerate(S):
            tmp = 0
            for k in s:
                tmp ^= switch[k-1]
            if tmp==P[i]:
                continue
            else:
                break
        else:
            ans += 1

    print(ans) def main():
    N, M = map(int, readline().split())
    S = []
    for _ in range(M):
        k, *s = map(int, readline().split())
        S.append(s)
    P = list(map(int, readline().split()))
    ans = 0

    for switch in product((0,1),repeat=N):
        for i, s in enumerate(S):
            tmp = 0
            for k in s:
                tmp ^= switch[k-1]
            if tmp==P[i]:
                continue
            else:
                break
        else:
            ans += 1

    print(ans) main readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline INF = float('inf') float('inf') INF MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from itertools import product
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N, M = map(int, readline().split())
    S = []
    for _ in range(M):
        k, *s = map(int, readline().split())
        S.append(s)
    P = list(map(int, readline().split()))
    ans = 0

    for switch in product((0,1),repeat=N):
        for i, s in enumerate(S):
            tmp = 0
            for k in s:
                tmp ^= switch[k-1]
            if tmp==P[i]:
                continue
            else:
                break
        else:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

