#! /usr/bin/env python3
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def bit_search(n):
    res = []
    for i in range(2**n):
        st = set()
        for j in range(n): 
            if ((i >> j) & 1):
                st.add(j)
        res.append(st)
    return res

def main():
    N,M=mi()
    X = {}
    for i in range(M):
        inp = list(mi())
        X[i] = inp[1:]
    
    P = list(mi())

    ans = 0
    for combs in bit_search(N):
        res = 0
        for i in range(M):
            on_count = 0
            for j in range(len(X[i])):
                s = X[i][j] - 1 # 0-index
                if s in combs:
                    on_count += 1
            
            if on_count % 2 == P[i]:
                res += 1

        if res == M:
            ans += 1


    print(ans)
                    





if __name__ == "__main__":
    main() import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 def mi(): return map(int,input().split()) mi def ii(): return int(input()) ii def isp(): return input().split() isp def deb(text): print("-------\n{}\n-------".format(text)) deb text text INF=10**20 INF 10**20 10 20 def bit_search(n):
    res = []
    for i in range(2**n):
        st = set()
        for j in range(n): 
            if ((i >> j) & 1):
                st.add(j)
        res.append(st)
    return res bit_search res = [] res [] for i in range(2**n):
        st = set()
        for j in range(n): 
            if ((i >> j) & 1):
                st.add(j)
        res.append(st)
     i range(2**n) range 2**n 2 n st = set() st set() set for j in range(n): 
            if ((i >> j) & 1):
                st.add(j)
         j range(n) range n if ((i >> j) & 1):
                st.add(j)
         (i >> j) & 1 i >> j i j 1 st.add(j) st.add st add j res.append(st) res.append res append st return res res n n def main():
    N,M=mi()
    X = {}
    for i in range(M):
        inp = list(mi())
        X[i] = inp[1:]
    
    P = list(mi())

    ans = 0
    for combs in bit_search(N):
        res = 0
        for i in range(M):
            on_count = 0
            for j in range(len(X[i])):
                s = X[i][j] - 1 # 0-index
                if s in combs:
                    on_count += 1
            
            if on_count % 2 == P[i]:
                res += 1

        if res == M:
            ans += 1


    print(ans)
                     main N,M=mi() N mi() mi M X = {} X {} for i in range(M):
        inp = list(mi())
        X[i] = inp[1:]
    
     i range(M) range M inp = list(mi()) inp list(mi()) list mi() mi X[i] = inp[1:] X[i] X i inp[1:] inp 1: 1 P = list(mi()) P list(mi()) list mi() mi ans = 0 ans 0 for combs in bit_search(N):
        res = 0
        for i in range(M):
            on_count = 0
            for j in range(len(X[i])):
                s = X[i][j] - 1 # 0-index
                if s in combs:
                    on_count += 1
            
            if on_count % 2 == P[i]:
                res += 1

        if res == M:
            ans += 1


     combs bit_search(N) bit_search N res = 0 res 0 for i in range(M):
            on_count = 0
            for j in range(len(X[i])):
                s = X[i][j] - 1 # 0-index
                if s in combs:
                    on_count += 1
            
            if on_count % 2 == P[i]:
                res += 1

         i range(M) range M on_count = 0 on_count 0 for j in range(len(X[i])):
                s = X[i][j] - 1 # 0-index
                if s in combs:
                    on_count += 1
            
             j range(len(X[i])) range len(X[i]) len X[i] X i s = X[i][j] - 1 s X[i][j] - 1 X[i][j] [i] X i j 1 if s in combs:
                    on_count += 1
            
             s in combs s combs on_count += 1 on_count 1 if on_count % 2 == P[i]:
                res += 1

         on_count % 2 == P[i] on_count % 2 on_count 2 P[i] P i res += 1 res 1 if res == M:
            ans += 1


     res == M res M ans += 1 ans 1 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def ii(): return int(input()) def ii(): return int(input()) ii INF=10**20 10**20 INF def mi(): return map(int,input().split()) def mi(): return map(int,input().split()) mi def deb(text): print("-------\n{}\n-------".format(text)) def deb(text): print("-------\n{}\n-------".format(text)) deb def main():
    N,M=mi()
    X = {}
    for i in range(M):
        inp = list(mi())
        X[i] = inp[1:]
    
    P = list(mi())

    ans = 0
    for combs in bit_search(N):
        res = 0
        for i in range(M):
            on_count = 0
            for j in range(len(X[i])):
                s = X[i][j] - 1 # 0-index
                if s in combs:
                    on_count += 1
            
            if on_count % 2 == P[i]:
                res += 1

        if res == M:
            ans += 1


    print(ans)
                     def main():
    N,M=mi()
    X = {}
    for i in range(M):
        inp = list(mi())
        X[i] = inp[1:]
    
    P = list(mi())

    ans = 0
    for combs in bit_search(N):
        res = 0
        for i in range(M):
            on_count = 0
            for j in range(len(X[i])):
                s = X[i][j] - 1 # 0-index
                if s in combs:
                    on_count += 1
            
            if on_count % 2 == P[i]:
                res += 1

        if res == M:
            ans += 1


    print(ans)
                     main def isp(): return input().split() def isp(): return input().split() isp def bit_search(n):
    res = []
    for i in range(2**n):
        st = set()
        for j in range(n): 
            if ((i >> j) & 1):
                st.add(j)
        res.append(st)
    return res def bit_search(n):
    res = []
    for i in range(2**n):
        st = set()
        for j in range(n): 
            if ((i >> j) & 1):
                st.add(j)
        res.append(st)
    return res bit_search
#! /usr/bin/env python3
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def bit_search(n):
    res = []
    for i in range(2**n):
        st = set()
        for j in range(n): 
            if ((i >> j) & 1):
                st.add(j)
        res.append(st)
    return res

def main():
    N,M=mi()
    X = {}
    for i in range(M):
        inp = list(mi())
        X[i] = inp[1:]
    
    P = list(mi())

    ans = 0
    for combs in bit_search(N):
        res = 0
        for i in range(M):
            on_count = 0
            for j in range(len(X[i])):
                s = X[i][j] - 1 # 0-index
                if s in combs:
                    on_count += 1
            
            if on_count % 2 == P[i]:
                res += 1

        if res == M:
            ans += 1


    print(ans)
                    





if __name__ == "__main__":
    main()