N = None
M = None
S = []
P = []

if __name__ == "__main__":
    N, M = map(int, input().split())
    for _ in range(M):
        row = list(map(int, input().split()))[1:]
        S.append(row)
    P = list(map(int, input().split()))
    ans = 0
    for bit in range(1<<N):
        on_switches = []
        light = 0
        for i in range(N):
            if bit>>i&1:
                on_switches.append(i)
        for i in range(M):
            cnt = 0
            for s in S[i]:
                for on_switch in on_switches:
                    if s==on_switch+1:
                        cnt += 1
            if cnt%2==P[i]:
                light += 1
        if light==M:
            ans += 1
    print(ans) N = None N None M = None M None S = [] S [] P = [] P [] if __name__ == "__main__":
    N, M = map(int, input().split())
    for _ in range(M):
        row = list(map(int, input().split()))[1:]
        S.append(row)
    P = list(map(int, input().split()))
    ans = 0
    for bit in range(1<<N):
        on_switches = []
        light = 0
        for i in range(N):
            if bit>>i&1:
                on_switches.append(i)
        for i in range(M):
            cnt = 0
            for s in S[i]:
                for on_switch in on_switches:
                    if s==on_switch+1:
                        cnt += 1
            if cnt%2==P[i]:
                light += 1
        if light==M:
            ans += 1
    print(ans) __name__ == "__main__" __name__ "__main__" N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M for _ in range(M):
        row = list(map(int, input().split()))[1:]
        S.append(row)
     _ range(M) range M row = list(map(int, input().split()))[1:] row list(map(int, input().split()))[1:] (map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 1: 1 S.append(row) S.append S append row 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 = []
        light = 0
        for i in range(N):
            if bit>>i&1:
                on_switches.append(i)
        for i in range(M):
            cnt = 0
            for s in S[i]:
                for on_switch in on_switches:
                    if s==on_switch+1:
                        cnt += 1
            if cnt%2==P[i]:
                light += 1
        if light==M:
            ans += 1
     bit range(1<<N) range 1<<N 1 N on_switches = [] on_switches [] light = 0 light 0 for i in range(N):
            if bit>>i&1:
                on_switches.append(i)
         i range(N) range N if bit>>i&1:
                on_switches.append(i)
         bit>>i&1 bit>>i bit i 1 on_switches.append(i) on_switches.append on_switches append i for i in range(M):
            cnt = 0
            for s in S[i]:
                for on_switch in on_switches:
                    if s==on_switch+1:
                        cnt += 1
            if cnt%2==P[i]:
                light += 1
         i range(M) range M cnt = 0 cnt 0 for s in S[i]:
                for on_switch in on_switches:
                    if s==on_switch+1:
                        cnt += 1
             s S[i] S i for on_switch in on_switches:
                    if s==on_switch+1:
                        cnt += 1
             on_switch on_switches if s==on_switch+1:
                        cnt += 1
             s==on_switch+1 s on_switch+1 on_switch 1 cnt += 1 cnt 1 if cnt%2==P[i]:
                light += 1
         cnt%2==P[i] cnt%2 cnt 2 P[i] P i light += 1 light 1 if light==M:
            ans += 1
     light==M light M ans += 1 ans 1 print(ans) print ans ans += 1 1 ans S = [] [] S M = map(int, input().split()) map(int, input().split()) M N = None None N ans = 0 0 ans cnt += 1 1 cnt light = 0 0 light row = list(map(int, input().split()))[1:] list(map(int, input().split()))[1:] row cnt = 0 0 cnt P = list(map(int, input().split())) list(map(int, input().split())) P on_switches = [] [] on_switches M = None None M light += 1 1 light P = [] [] P N, M = map(int, input().split()) map(int, input().split()) N
N = None
M = None
S = []
P = []

if __name__ == "__main__":
    N, M = map(int, input().split())
    for _ in range(M):
        row = list(map(int, input().split()))[1:]
        S.append(row)
    P = list(map(int, input().split()))
    ans = 0
    for bit in range(1<<N):
        on_switches = []
        light = 0
        for i in range(N):
            if bit>>i&1:
                on_switches.append(i)
        for i in range(M):
            cnt = 0
            for s in S[i]:
                for on_switch in on_switches:
                    if s==on_switch+1:
                        cnt += 1
            if cnt%2==P[i]:
                light += 1
        if light==M:
            ans += 1
    print(ans)