n,m = map(int,input().split())
dic = {}
for i in range(m):
    s = list(map(int,input().split()))[1:]
    dic[i] = s
P = list(map(int,input().split()))
# print(dic)

ans = 0

# ON/OFFをbit全探索
for i in range(2**n):
    on_off = [False]*n
    for j in range(n):
        if ((i>>j)&1):
            on_off[j] = True
    flag = True
    for k in range(m):
        cnt = 0
        for l in dic[k]:
            if on_off[l-1]:
                cnt += 1
        if cnt % 2 != P[k]:
            flag = False
    if flag:
        ans += 1
print(ans) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m dic = {} dic {} for i in range(m):
    s = list(map(int,input().split()))[1:]
    dic[i] = s i range(m) range m s = list(map(int,input().split()))[1:] s list(map(int,input().split()))[1:] (map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split 1: 1 dic[i] = s dic[i] dic i 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):
    on_off = [False]*n
    for j in range(n):
        if ((i>>j)&1):
            on_off[j] = True
    flag = True
    for k in range(m):
        cnt = 0
        for l in dic[k]:
            if on_off[l-1]:
                cnt += 1
        if cnt % 2 != P[k]:
            flag = False
    if flag:
        ans += 1 i range(2**n) range 2**n 2 n on_off = [False]*n on_off [False]*n [False] False n for j in range(n):
        if ((i>>j)&1):
            on_off[j] = True
     j range(n) range n if ((i>>j)&1):
            on_off[j] = True
     (i>>j)&1 i>>j i j 1 on_off[j] = True on_off[j] on_off j True flag = True flag True for k in range(m):
        cnt = 0
        for l in dic[k]:
            if on_off[l-1]:
                cnt += 1
        if cnt % 2 != P[k]:
            flag = False
     k range(m) range m cnt = 0 cnt 0 for l in dic[k]:
            if on_off[l-1]:
                cnt += 1
         l dic[k] dic k if on_off[l-1]:
                cnt += 1
         on_off[l-1] on_off l-1 l 1 cnt += 1 cnt 1 if cnt % 2 != P[k]:
            flag = False
     cnt % 2 != P[k] cnt % 2 cnt 2 P[k] P k flag = False flag False if flag:
        ans += 1 flag ans += 1 ans 1 print(ans) print ans dic = {} {} dic m = map(int,input().split()) map(int,input().split()) m s = list(map(int,input().split()))[1:] list(map(int,input().split()))[1:] s on_off = [False]*n [False]*n on_off cnt += 1 1 cnt flag = True True flag cnt = 0 0 cnt P = list(map(int,input().split())) list(map(int,input().split())) P ans = 0 0 ans n,m = map(int,input().split()) map(int,input().split()) n flag = False False flag ans += 1 1 ans
n,m = map(int,input().split())
dic = {}
for i in range(m):
    s = list(map(int,input().split()))[1:]
    dic[i] = s
P = list(map(int,input().split()))
# print(dic)

ans = 0

# ON/OFFをbit全探索
for i in range(2**n):
    on_off = [False]*n
    for j in range(n):
        if ((i>>j)&1):
            on_off[j] = True
    flag = True
    for k in range(m):
        cnt = 0
        for l in dic[k]:
            if on_off[l-1]:
                cnt += 1
        if cnt % 2 != P[k]:
            flag = False
    if flag:
        ans += 1
print(ans)