n, m = map(int, input().split())
bulbs = []
ans = 0
for i in range(m):
    c = tuple(map(int, input().split()))
    bulbs.append(c[1:])
p = list(map(int, input().split()))
for i in range(2 ** n):
    cnt = 0
    for j, bulbs_sub in enumerate(bulbs):
        switch_on = 0
        for l in bulbs_sub:
            if i >> (l-1) & 1:
                switch_on += 1
        if switch_on % 2 == p[j]:
                cnt += 1
    if cnt == m:
        ans += 1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m bulbs = [] bulbs [] ans = 0 ans 0 for i in range(m):
    c = tuple(map(int, input().split()))
    bulbs.append(c[1:]) i range(m) range m c = tuple(map(int, input().split())) c tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split bulbs.append(c[1:]) bulbs.append bulbs append c[1:] c 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 for i in range(2 ** n):
    cnt = 0
    for j, bulbs_sub in enumerate(bulbs):
        switch_on = 0
        for l in bulbs_sub:
            if i >> (l-1) & 1:
                switch_on += 1
        if switch_on % 2 == p[j]:
                cnt += 1
    if cnt == m:
        ans += 1 i range(2 ** n) range 2 ** n 2 n cnt = 0 cnt 0 for j, bulbs_sub in enumerate(bulbs):
        switch_on = 0
        for l in bulbs_sub:
            if i >> (l-1) & 1:
                switch_on += 1
        if switch_on % 2 == p[j]:
                cnt += 1
     j bulbs_sub enumerate(bulbs) enumerate bulbs switch_on = 0 switch_on 0 for l in bulbs_sub:
            if i >> (l-1) & 1:
                switch_on += 1
         l bulbs_sub if i >> (l-1) & 1:
                switch_on += 1
         i >> (l-1) & 1 i >> (l-1) i l-1 l 1 1 switch_on += 1 switch_on 1 if switch_on % 2 == p[j]:
                cnt += 1
     switch_on % 2 == p[j] switch_on % 2 switch_on 2 p[j] p j cnt += 1 cnt 1 if cnt == m:
        ans += 1 cnt == m cnt m ans += 1 ans 1 print(ans) print ans bulbs = [] [] bulbs n, m = map(int, input().split()) map(int, input().split()) n m = map(int, input().split()) map(int, input().split()) m p = list(map(int, input().split())) list(map(int, input().split())) p cnt = 0 0 cnt ans = 0 0 ans switch_on += 1 1 switch_on ans += 1 1 ans cnt += 1 1 cnt c = tuple(map(int, input().split())) tuple(map(int, input().split())) c switch_on = 0 0 switch_on
n, m = map(int, input().split())
bulbs = []
ans = 0
for i in range(m):
    c = tuple(map(int, input().split()))
    bulbs.append(c[1:])
p = list(map(int, input().split()))
for i in range(2 ** n):
    cnt = 0
    for j, bulbs_sub in enumerate(bulbs):
        switch_on = 0
        for l in bulbs_sub:
            if i >> (l-1) & 1:
                switch_on += 1
        if switch_on % 2 == p[j]:
                cnt += 1
    if cnt == m:
        ans += 1
print(ans)