def main():
    n, m = map(int, input().split())
    ks = []
    for _ in range(m):
        ks.append(list(map(int, input().split())))
    p = list(map(int, input().split()))

    ans = 0
    for i in range(2**n):
        ls = [0]*m
        for j in range(n):
            if i & (1 << j):
                for k in range(m):
                    if j+1 in ks[k][1:]:
                        ls[k] += 1
        cnt = 0
        for l in range(m):
            if ls[l] % 2 == p[l]:
                cnt += 1
        if cnt == m:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main() def main():
    n, m = map(int, input().split())
    ks = []
    for _ in range(m):
        ks.append(list(map(int, input().split())))
    p = list(map(int, input().split()))

    ans = 0
    for i in range(2**n):
        ls = [0]*m
        for j in range(n):
            if i & (1 << j):
                for k in range(m):
                    if j+1 in ks[k][1:]:
                        ls[k] += 1
        cnt = 0
        for l in range(m):
            if ls[l] % 2 == p[l]:
                cnt += 1
        if cnt == m:
            ans += 1

    print(ans) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m ks = [] ks [] for _ in range(m):
        ks.append(list(map(int, input().split())))
     _ range(m) range m ks.append(list(map(int, input().split()))) ks.append ks append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split p = list(map(int, input().split())) p list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split ans = 0 ans 0 for i in range(2**n):
        ls = [0]*m
        for j in range(n):
            if i & (1 << j):
                for k in range(m):
                    if j+1 in ks[k][1:]:
                        ls[k] += 1
        cnt = 0
        for l in range(m):
            if ls[l] % 2 == p[l]:
                cnt += 1
        if cnt == m:
            ans += 1

     i range(2**n) range 2**n 2 n ls = [0]*m ls [0]*m [0] 0 m for j in range(n):
            if i & (1 << j):
                for k in range(m):
                    if j+1 in ks[k][1:]:
                        ls[k] += 1
         j range(n) range n if i & (1 << j):
                for k in range(m):
                    if j+1 in ks[k][1:]:
                        ls[k] += 1
         i & (1 << j) i 1 << j 1 j for k in range(m):
                    if j+1 in ks[k][1:]:
                        ls[k] += 1
         k range(m) range m if j+1 in ks[k][1:]:
                        ls[k] += 1
         j+1 in ks[k][1:] j+1 j 1 ks[k][1:] [k] ks k 1: 1 ls[k] += 1 ls[k] ls k 1 cnt = 0 cnt 0 for l in range(m):
            if ls[l] % 2 == p[l]:
                cnt += 1
         l range(m) range m if ls[l] % 2 == p[l]:
                cnt += 1
         ls[l] % 2 == p[l] ls[l] % 2 ls[l] ls l 2 p[l] p l cnt += 1 cnt 1 if cnt == m:
            ans += 1

     cnt == m cnt m ans += 1 ans 1 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n, m = map(int, input().split())
    ks = []
    for _ in range(m):
        ks.append(list(map(int, input().split())))
    p = list(map(int, input().split()))

    ans = 0
    for i in range(2**n):
        ls = [0]*m
        for j in range(n):
            if i & (1 << j):
                for k in range(m):
                    if j+1 in ks[k][1:]:
                        ls[k] += 1
        cnt = 0
        for l in range(m):
            if ls[l] % 2 == p[l]:
                cnt += 1
        if cnt == m:
            ans += 1

    print(ans) def main():
    n, m = map(int, input().split())
    ks = []
    for _ in range(m):
        ks.append(list(map(int, input().split())))
    p = list(map(int, input().split()))

    ans = 0
    for i in range(2**n):
        ls = [0]*m
        for j in range(n):
            if i & (1 << j):
                for k in range(m):
                    if j+1 in ks[k][1:]:
                        ls[k] += 1
        cnt = 0
        for l in range(m):
            if ls[l] % 2 == p[l]:
                cnt += 1
        if cnt == m:
            ans += 1

    print(ans) main
def main():
    n, m = map(int, input().split())
    ks = []
    for _ in range(m):
        ks.append(list(map(int, input().split())))
    p = list(map(int, input().split()))

    ans = 0
    for i in range(2**n):
        ls = [0]*m
        for j in range(n):
            if i & (1 << j):
                for k in range(m):
                    if j+1 in ks[k][1:]:
                        ls[k] += 1
        cnt = 0
        for l in range(m):
            if ls[l] % 2 == p[l]:
                cnt += 1
        if cnt == m:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()
