import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,m = map(int, input().split())
    ans = 0
    S = []
    for i in range(m):
        s = list(map(int, input().split()))
        k = s.pop(0)
        S.append(s)
    p = list(map(int, input().split()))

    for i in range(1<<n):
        ok = True
        for j in range(m):
            cnt = 0
            for s in S[j]:
                if ((i>>s-1)&1): # スイッチが対象であれば
                    cnt += 1
            if cnt%2!=p[j]:
                ok = False
        if ok:
            ans += 1
    print(ans)




if __name__=="__main__":
    main() import math math from math import gcd INF = float("inf") INF float("inf") float "inf" import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline sys.setrecursionlimit(500*500) sys.setrecursionlimit sys setrecursionlimit 500*500 500 500 import itertools itertools from collections import Counter,deque def main():
    n,m = map(int, input().split())
    ans = 0
    S = []
    for i in range(m):
        s = list(map(int, input().split()))
        k = s.pop(0)
        S.append(s)
    p = list(map(int, input().split()))

    for i in range(1<<n):
        ok = True
        for j in range(m):
            cnt = 0
            for s in S[j]:
                if ((i>>s-1)&1): # スイッチが対象であれば
                    cnt += 1
            if cnt%2!=p[j]:
                ok = False
        if ok:
            ans += 1
    print(ans) main n,m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m ans = 0 ans 0 S = [] S [] for i in range(m):
        s = list(map(int, input().split()))
        k = s.pop(0)
        S.append(s)
     i range(m) range m s = list(map(int, input().split())) s list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k = s.pop(0) k s.pop(0) s.pop s pop 0 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 for i in range(1<<n):
        ok = True
        for j in range(m):
            cnt = 0
            for s in S[j]:
                if ((i>>s-1)&1): # スイッチが対象であれば
                    cnt += 1
            if cnt%2!=p[j]:
                ok = False
        if ok:
            ans += 1
     i range(1<<n) range 1<<n 1 n ok = True ok True for j in range(m):
            cnt = 0
            for s in S[j]:
                if ((i>>s-1)&1): # スイッチが対象であれば
                    cnt += 1
            if cnt%2!=p[j]:
                ok = False
         j range(m) range m cnt = 0 cnt 0 for s in S[j]:
                if ((i>>s-1)&1): # スイッチが対象であれば
                    cnt += 1
             s S[j] S j if ((i>>s-1)&1): # スイッチが対象であれば
                    cnt += 1
             (i>>s-1)&1 i>>s-1 i s-1 s 1 1 cnt += 1 cnt 1 if cnt%2!=p[j]:
                ok = False
         cnt%2!=p[j] cnt%2 cnt 2 p[j] p j ok = False ok False if ok:
            ans += 1
     ok 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())
    ans = 0
    S = []
    for i in range(m):
        s = list(map(int, input().split()))
        k = s.pop(0)
        S.append(s)
    p = list(map(int, input().split()))

    for i in range(1<<n):
        ok = True
        for j in range(m):
            cnt = 0
            for s in S[j]:
                if ((i>>s-1)&1): # スイッチが対象であれば
                    cnt += 1
            if cnt%2!=p[j]:
                ok = False
        if ok:
            ans += 1
    print(ans) def main():
    n,m = map(int, input().split())
    ans = 0
    S = []
    for i in range(m):
        s = list(map(int, input().split()))
        k = s.pop(0)
        S.append(s)
    p = list(map(int, input().split()))

    for i in range(1<<n):
        ok = True
        for j in range(m):
            cnt = 0
            for s in S[j]:
                if ((i>>s-1)&1): # スイッチが対象であれば
                    cnt += 1
            if cnt%2!=p[j]:
                ok = False
        if ok:
            ans += 1
    print(ans) main input=sys.stdin.readline sys.stdin.readline input INF = float("inf") float("inf") INF
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    n,m = map(int, input().split())
    ans = 0
    S = []
    for i in range(m):
        s = list(map(int, input().split()))
        k = s.pop(0)
        S.append(s)
    p = list(map(int, input().split()))

    for i in range(1<<n):
        ok = True
        for j in range(m):
            cnt = 0
            for s in S[j]:
                if ((i>>s-1)&1): # スイッチが対象であれば
                    cnt += 1
            if cnt%2!=p[j]:
                ok = False
        if ok:
            ans += 1
    print(ans)




if __name__=="__main__":
    main()
