n,m = map(int,input().split())
l = []
for i in range(1 << n):
    tmp = str(bin(i))[2:]
    l.append(tmp.zfill(n))
K = [list(map(int,input().split())) for _ in range(m)]
P = list(map(int,input().split()))
#print(P)
ans = 0
#print("----")
for i in range(len(l)):
    #スイッチの状態l[i]
    #付いている電球のリストO
    O = []
    for j in range(m):
        #電球のきになるすいっちの数K[j][0]
        ON = 0
        for ii in range(K[j][0]): #スイッチのリスト
            if l[i][K[j][ii+1] - 1] == "1":
                ON += 1
        if ON % 2 == P[j]:
            O.append(1)
        else:
            O.append(0)
    if sum(O) == m:
        #print(l[i])
        ans += 1
print(ans)
 n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m l = [] l [] for i in range(1 << n):
    tmp = str(bin(i))[2:]
    l.append(tmp.zfill(n)) i range(1 << n) range 1 << n 1 n tmp = str(bin(i))[2:] tmp str(bin(i))[2:] (bin(i)) str bin(i) bin i 2: 2 l.append(tmp.zfill(n)) l.append l append tmp.zfill(n) tmp.zfill tmp zfill n list(map(int,input().split())) for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split K = [list(map(int,input().split())) for _ in range(m)] K [list(map(int,input().split())) for _ in range(m)] 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(len(l)):
    #スイッチの状態l[i]
    #付いている電球のリストO
    O = []
    for j in range(m):
        #電球のきになるすいっちの数K[j][0]
        ON = 0
        for ii in range(K[j][0]): #スイッチのリスト
            if l[i][K[j][ii+1] - 1] == "1":
                ON += 1
        if ON % 2 == P[j]:
            O.append(1)
        else:
            O.append(0)
    if sum(O) == m:
        #print(l[i])
        ans += 1 i range(len(l)) range len(l) len l O = [] O [] for j in range(m):
        #電球のきになるすいっちの数K[j][0]
        ON = 0
        for ii in range(K[j][0]): #スイッチのリスト
            if l[i][K[j][ii+1] - 1] == "1":
                ON += 1
        if ON % 2 == P[j]:
            O.append(1)
        else:
            O.append(0)
     j range(m) range m ON = 0 ON 0 for ii in range(K[j][0]): #スイッチのリスト
            if l[i][K[j][ii+1] - 1] == "1":
                ON += 1
         ii range(K[j][0]) range K[j][0] [j] K j 0 if l[i][K[j][ii+1] - 1] == "1":
                ON += 1
         l[i][K[j][ii+1] - 1] == "1" l[i][K[j][ii+1] - 1] [i] l i K[j][ii+1] - 1 K[j][ii+1] [j] K j ii+1 ii 1 1 "1" ON += 1 ON 1 if ON % 2 == P[j]:
            O.append(1)
        else:
            O.append(0)
     ON % 2 == P[j] ON % 2 ON 2 P[j] P j O.append(1) O.append O append 1 O.append(0) O.append O append 0 if sum(O) == m:
        #print(l[i])
        ans += 1 sum(O) == m sum(O) sum O m ans += 1 ans 1 print(ans) print ans ON = 0 0 ON l = [] [] l ans = 0 0 ans m = map(int,input().split()) map(int,input().split()) m P = list(map(int,input().split())) list(map(int,input().split())) P ON += 1 1 ON K = [list(map(int,input().split())) for _ in range(m)] [list(map(int,input().split())) for _ in range(m)] K O = [] [] O n,m = map(int,input().split()) map(int,input().split()) n tmp = str(bin(i))[2:] str(bin(i))[2:] tmp ans += 1 1 ans
n,m = map(int,input().split())
l = []
for i in range(1 << n):
    tmp = str(bin(i))[2:]
    l.append(tmp.zfill(n))
K = [list(map(int,input().split())) for _ in range(m)]
P = list(map(int,input().split()))
#print(P)
ans = 0
#print("----")
for i in range(len(l)):
    #スイッチの状態l[i]
    #付いている電球のリストO
    O = []
    for j in range(m):
        #電球のきになるすいっちの数K[j][0]
        ON = 0
        for ii in range(K[j][0]): #スイッチのリスト
            if l[i][K[j][ii+1] - 1] == "1":
                ON += 1
        if ON % 2 == P[j]:
            O.append(1)
        else:
            O.append(0)
    if sum(O) == m:
        #print(l[i])
        ans += 1
print(ans)

