def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, m = map(int, input().split())
    S = []
    for i in range(m):
        k, *s = map(int, input().split())
        s = [i-1 for i in s]
        S.append(s)
    p = list(map(int, input().split()))
    ans = 0
    for i in range(2**n):
        check = [False]*m
        for j in range(m):
            s = S[j]
            cnt = 0
            for idx in s:
                if (i>>idx)&1:
                    cnt += 1
            if cnt%2 == p[j]:
                check[j] = True
        if not False in check:
            ans += 1
    print(ans)

        

if __name__ == '__main__':
    main() def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, m = map(int, input().split())
    S = []
    for i in range(m):
        k, *s = map(int, input().split())
        s = [i-1 for i in s]
        S.append(s)
    p = list(map(int, input().split()))
    ans = 0
    for i in range(2**n):
        check = [False]*m
        for j in range(m):
            s = S[j]
            cnt = 0
            for idx in s:
                if (i>>idx)&1:
                    cnt += 1
            if cnt%2 == p[j]:
                check[j] = True
        if not False in check:
            ans += 1
    print(ans)

         main import sys sys def input(): return sys.stdin.readline().rstrip()
     input n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m S = [] S [] for i in range(m):
        k, *s = map(int, input().split())
        s = [i-1 for i in s]
        S.append(s)
     i range(m) range m k, *s = map(int, input().split()) k map(int, input().split()) map int input().split() ().split () input split *s s i-1 for i in s for i in s i s for i in s i-1 i 1 s = [i-1 for i in s] s [i-1 for i in s] S.append(s) S.append S append s 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):
        check = [False]*m
        for j in range(m):
            s = S[j]
            cnt = 0
            for idx in s:
                if (i>>idx)&1:
                    cnt += 1
            if cnt%2 == p[j]:
                check[j] = True
        if not False in check:
            ans += 1
     i range(2**n) range 2**n 2 n check = [False]*m check [False]*m [False] False m for j in range(m):
            s = S[j]
            cnt = 0
            for idx in s:
                if (i>>idx)&1:
                    cnt += 1
            if cnt%2 == p[j]:
                check[j] = True
         j range(m) range m s = S[j] s S[j] S j cnt = 0 cnt 0 for idx in s:
                if (i>>idx)&1:
                    cnt += 1
             idx s if (i>>idx)&1:
                    cnt += 1
             (i>>idx)&1 i>>idx i idx 1 cnt += 1 cnt 1 if cnt%2 == p[j]:
                check[j] = True
         cnt%2 == p[j] cnt%2 cnt 2 p[j] p j check[j] = True check[j] check j True if not False in check:
            ans += 1
     not False in check False in check False check ans += 1 ans 1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, m = map(int, input().split())
    S = []
    for i in range(m):
        k, *s = map(int, input().split())
        s = [i-1 for i in s]
        S.append(s)
    p = list(map(int, input().split()))
    ans = 0
    for i in range(2**n):
        check = [False]*m
        for j in range(m):
            s = S[j]
            cnt = 0
            for idx in s:
                if (i>>idx)&1:
                    cnt += 1
            if cnt%2 == p[j]:
                check[j] = True
        if not False in check:
            ans += 1
    print(ans)

         def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, m = map(int, input().split())
    S = []
    for i in range(m):
        k, *s = map(int, input().split())
        s = [i-1 for i in s]
        S.append(s)
    p = list(map(int, input().split()))
    ans = 0
    for i in range(2**n):
        check = [False]*m
        for j in range(m):
            s = S[j]
            cnt = 0
            for idx in s:
                if (i>>idx)&1:
                    cnt += 1
            if cnt%2 == p[j]:
                check[j] = True
        if not False in check:
            ans += 1
    print(ans)

         main
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, m = map(int, input().split())
    S = []
    for i in range(m):
        k, *s = map(int, input().split())
        s = [i-1 for i in s]
        S.append(s)
    p = list(map(int, input().split()))
    ans = 0
    for i in range(2**n):
        check = [False]*m
        for j in range(m):
            s = S[j]
            cnt = 0
            for idx in s:
                if (i>>idx)&1:
                    cnt += 1
            if cnt%2 == p[j]:
                check[j] = True
        if not False in check:
            ans += 1
    print(ans)

        

if __name__ == '__main__':
    main()