def main():
    N, M = map(int, input().split())
    S = []
    for _ in range(M):
        S.append(set(list(map(int, input().split()))[1:]))
    P = list(map(int, input().split()))

    ans = 0
    for bit in range(1 << N):
        on_switches = set([])
        for i in range(N):
            if bit & (1 << i):
                on_switches.add(i + 1)

        flag = True
        for s, p in zip(S, P):
            if len(s & on_switches) % 2 != p:
                flag = False
        if flag is True:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main() def main():
    N, M = map(int, input().split())
    S = []
    for _ in range(M):
        S.append(set(list(map(int, input().split()))[1:]))
    P = list(map(int, input().split()))

    ans = 0
    for bit in range(1 << N):
        on_switches = set([])
        for i in range(N):
            if bit & (1 << i):
                on_switches.add(i + 1)

        flag = True
        for s, p in zip(S, P):
            if len(s & on_switches) % 2 != p:
                flag = False
        if flag is True:
            ans += 1
    print(ans) main N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M S = [] S [] for _ in range(M):
        S.append(set(list(map(int, input().split()))[1:]))
     _ range(M) range M S.append(set(list(map(int, input().split()))[1:])) S.append S append set(list(map(int, input().split()))[1:]) set list(map(int, input().split()))[1:] (map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 1: 1 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 bit in range(1 << N):
        on_switches = set([])
        for i in range(N):
            if bit & (1 << i):
                on_switches.add(i + 1)

        flag = True
        for s, p in zip(S, P):
            if len(s & on_switches) % 2 != p:
                flag = False
        if flag is True:
            ans += 1
     bit range(1 << N) range 1 << N 1 N on_switches = set([]) on_switches set([]) set [] for i in range(N):
            if bit & (1 << i):
                on_switches.add(i + 1)

         i range(N) range N if bit & (1 << i):
                on_switches.add(i + 1)

         bit & (1 << i) bit 1 << i 1 i on_switches.add(i + 1) on_switches.add on_switches add i + 1 i 1 flag = True flag True for s, p in zip(S, P):
            if len(s & on_switches) % 2 != p:
                flag = False
         s p zip(S, P) zip S P if len(s & on_switches) % 2 != p:
                flag = False
         len(s & on_switches) % 2 != p len(s & on_switches) % 2 len(s & on_switches) len s & on_switches s on_switches 2 p flag = False flag False if flag is True:
            ans += 1
     flag is True flag True 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())
    S = []
    for _ in range(M):
        S.append(set(list(map(int, input().split()))[1:]))
    P = list(map(int, input().split()))

    ans = 0
    for bit in range(1 << N):
        on_switches = set([])
        for i in range(N):
            if bit & (1 << i):
                on_switches.add(i + 1)

        flag = True
        for s, p in zip(S, P):
            if len(s & on_switches) % 2 != p:
                flag = False
        if flag is True:
            ans += 1
    print(ans) def main():
    N, M = map(int, input().split())
    S = []
    for _ in range(M):
        S.append(set(list(map(int, input().split()))[1:]))
    P = list(map(int, input().split()))

    ans = 0
    for bit in range(1 << N):
        on_switches = set([])
        for i in range(N):
            if bit & (1 << i):
                on_switches.add(i + 1)

        flag = True
        for s, p in zip(S, P):
            if len(s & on_switches) % 2 != p:
                flag = False
        if flag is True:
            ans += 1
    print(ans) main
def main():
    N, M = map(int, input().split())
    S = []
    for _ in range(M):
        S.append(set(list(map(int, input().split()))[1:]))
    P = list(map(int, input().split()))

    ans = 0
    for bit in range(1 << N):
        on_switches = set([])
        for i in range(N):
            if bit & (1 << i):
                on_switches.add(i + 1)

        flag = True
        for s, p in zip(S, P):
            if len(s & on_switches) % 2 != p:
                flag = False
        if flag is True:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()