n, m = list(map(int, input().split()))

switch = [[] for _ in range(m)]

for i in range(m):
    ks = list(map(int, input().split()))
    switch[i] = ks[1:]


p = list(map(int, input().split()))

ans = 0
#print(switch)

for i in range(2 ** n):
    flag = [False] * n
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            flag[j] = True

    #print(flag)
    f = True    
    for k in range(m):
        c = 0
        for j in switch[k]:
            if flag[j-1]:
                c += 1
        if c % 2 != p[k]:
            f = False
            break
        
    if f:
            ans += 1

print(ans)
 n, m = list(map(int, input().split())) n list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split m [] for _ in range(m) for _ in range(m) _ range(m) range m for _ in range(m) [] switch = [[] for _ in range(m)] switch [[] for _ in range(m)] for i in range(m):
    ks = list(map(int, input().split()))
    switch[i] = ks[1:] i range(m) range m ks = list(map(int, input().split())) ks list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split switch[i] = ks[1:] switch[i] switch i ks[1:] ks 1: 1 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):
    flag = [False] * n
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            flag[j] = True

    #print(flag)
    f = True    
    for k in range(m):
        c = 0
        for j in switch[k]:
            if flag[j-1]:
                c += 1
        if c % 2 != p[k]:
            f = False
            break
        
    if f:
            ans += 1 i range(2 ** n) range 2 ** n 2 n flag = [False] * n flag [False] * n [False] False n for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            flag[j] = True

    #print(flag)
     j range(n) range n if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            flag[j] = True

    #print(flag)
     (i >> j) & 1 i >> j i j 1 flag[j] = True flag[j] flag j True f = True f True for k in range(m):
        c = 0
        for j in switch[k]:
            if flag[j-1]:
                c += 1
        if c % 2 != p[k]:
            f = False
            break
        
     k range(m) range m c = 0 c 0 for j in switch[k]:
            if flag[j-1]:
                c += 1
         j switch[k] switch k if flag[j-1]:
                c += 1
         flag[j-1] flag j-1 j 1 c += 1 c 1 if c % 2 != p[k]:
            f = False
            break
        
     c % 2 != p[k] c % 2 c 2 p[k] p k f = False f False break if f:
            ans += 1 f ans += 1 ans 1 print(ans) print ans flag = [False] * n [False] * n flag c += 1 1 c f = False False f switch = [[] for _ in range(m)] [[] for _ in range(m)] switch p = list(map(int, input().split())) list(map(int, input().split())) p c = 0 0 c ks = list(map(int, input().split())) list(map(int, input().split())) ks f = True True f m = list(map(int, input().split())) list(map(int, input().split())) m n, m = list(map(int, input().split())) list(map(int, input().split())) n ans = 0 0 ans ans += 1 1 ans
n, m = list(map(int, input().split()))

switch = [[] for _ in range(m)]

for i in range(m):
    ks = list(map(int, input().split()))
    switch[i] = ks[1:]


p = list(map(int, input().split()))

ans = 0
#print(switch)

for i in range(2 ** n):
    flag = [False] * n
    for j in range(n):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            flag[j] = True

    #print(flag)
    f = True    
    for k in range(m):
        c = 0
        for j in switch[k]:
            if flag[j-1]:
                c += 1
        if c % 2 != p[k]:
            f = False
            break
        
    if f:
            ans += 1

print(ans)

