#!/usr/bin/env python3
def main():
    N, M = map(int, input().split())
    k, s = [], []
    for _ in range(M):
        lst = [int(x) - 1 for x in input().split()]
        k.append(lst.pop(0) + 1)
        s.append(set(lst))
    p = [int(x) for x in input().split()]

    ans = 0
    for bit in range(1 << N):
        now_on_switch = []
        for i in range(N):
            if bit & (1 << i):
                now_on_switch.append(i)
        lights = 0
        for i in range(M):
            cnt = 0
            for j in now_on_switch:
                cnt += 1 if j in s[i] else 0
            lights += 1 if cnt % 2 == p[i] else 0
        ans += 1 if lights == M else 0
    print(ans)


if __name__ == '__main__':
    main() def main():
    N, M = map(int, input().split())
    k, s = [], []
    for _ in range(M):
        lst = [int(x) - 1 for x in input().split()]
        k.append(lst.pop(0) + 1)
        s.append(set(lst))
    p = [int(x) for x in input().split()]

    ans = 0
    for bit in range(1 << N):
        now_on_switch = []
        for i in range(N):
            if bit & (1 << i):
                now_on_switch.append(i)
        lights = 0
        for i in range(M):
            cnt = 0
            for j in now_on_switch:
                cnt += 1 if j in s[i] else 0
            lights += 1 if cnt % 2 == p[i] else 0
        ans += 1 if lights == M else 0
    print(ans) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M k, s = [], [] k [] s [] for _ in range(M):
        lst = [int(x) - 1 for x in input().split()]
        k.append(lst.pop(0) + 1)
        s.append(set(lst))
     _ range(M) range M int(x) - 1 for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) - 1 int(x) int x 1 lst = [int(x) - 1 for x in input().split()] lst [int(x) - 1 for x in input().split()] k.append(lst.pop(0) + 1) k.append k append lst.pop(0) + 1 lst.pop(0) lst.pop lst pop 0 1 s.append(set(lst)) s.append s append set(lst) set lst int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x p = [int(x) for x in input().split()] p [int(x) for x in input().split()] ans = 0 ans 0 for bit in range(1 << N):
        now_on_switch = []
        for i in range(N):
            if bit & (1 << i):
                now_on_switch.append(i)
        lights = 0
        for i in range(M):
            cnt = 0
            for j in now_on_switch:
                cnt += 1 if j in s[i] else 0
            lights += 1 if cnt % 2 == p[i] else 0
        ans += 1 if lights == M else 0
     bit range(1 << N) range 1 << N 1 N now_on_switch = [] now_on_switch [] for i in range(N):
            if bit & (1 << i):
                now_on_switch.append(i)
         i range(N) range N if bit & (1 << i):
                now_on_switch.append(i)
         bit & (1 << i) bit 1 << i 1 i now_on_switch.append(i) now_on_switch.append now_on_switch append i lights = 0 lights 0 for i in range(M):
            cnt = 0
            for j in now_on_switch:
                cnt += 1 if j in s[i] else 0
            lights += 1 if cnt % 2 == p[i] else 0
         i range(M) range M cnt = 0 cnt 0 for j in now_on_switch:
                cnt += 1 if j in s[i] else 0
             j now_on_switch cnt += 1 if j in s[i] else 0 cnt 1 if j in s[i] else 0 j in s[i] j s[i] s i 1 0 lights += 1 if cnt % 2 == p[i] else 0 lights 1 if cnt % 2 == p[i] else 0 cnt % 2 == p[i] cnt % 2 cnt 2 p[i] p i 1 0 ans += 1 if lights == M else 0 ans 1 if lights == M else 0 lights == M lights M 1 0 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    N, M = map(int, input().split())
    k, s = [], []
    for _ in range(M):
        lst = [int(x) - 1 for x in input().split()]
        k.append(lst.pop(0) + 1)
        s.append(set(lst))
    p = [int(x) for x in input().split()]

    ans = 0
    for bit in range(1 << N):
        now_on_switch = []
        for i in range(N):
            if bit & (1 << i):
                now_on_switch.append(i)
        lights = 0
        for i in range(M):
            cnt = 0
            for j in now_on_switch:
                cnt += 1 if j in s[i] else 0
            lights += 1 if cnt % 2 == p[i] else 0
        ans += 1 if lights == M else 0
    print(ans) def main():
    N, M = map(int, input().split())
    k, s = [], []
    for _ in range(M):
        lst = [int(x) - 1 for x in input().split()]
        k.append(lst.pop(0) + 1)
        s.append(set(lst))
    p = [int(x) for x in input().split()]

    ans = 0
    for bit in range(1 << N):
        now_on_switch = []
        for i in range(N):
            if bit & (1 << i):
                now_on_switch.append(i)
        lights = 0
        for i in range(M):
            cnt = 0
            for j in now_on_switch:
                cnt += 1 if j in s[i] else 0
            lights += 1 if cnt % 2 == p[i] else 0
        ans += 1 if lights == M else 0
    print(ans) main
#!/usr/bin/env python3
def main():
    N, M = map(int, input().split())
    k, s = [], []
    for _ in range(M):
        lst = [int(x) - 1 for x in input().split()]
        k.append(lst.pop(0) + 1)
        s.append(set(lst))
    p = [int(x) for x in input().split()]

    ans = 0
    for bit in range(1 << N):
        now_on_switch = []
        for i in range(N):
            if bit & (1 << i):
                now_on_switch.append(i)
        lights = 0
        for i in range(M):
            cnt = 0
            for j in now_on_switch:
                cnt += 1 if j in s[i] else 0
            lights += 1 if cnt % 2 == p[i] else 0
        ans += 1 if lights == M else 0
    print(ans)


if __name__ == '__main__':
    main()
