n,m = map(int,input().split())
s = []
for _ in range(m):
    tmp = list(map(int,input().split()))
    s.append(tmp[1:])
p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
    for j in range(m):
        count = 0
        check = True
        for k in s[j]:
            if (i >> (k-1)) & 1:
                count += 1
        if count % 2 != p[j]:
            check = False
            break
    if check:
        ans += 1
print(ans) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m s = [] s [] for _ in range(m):
    tmp = list(map(int,input().split()))
    s.append(tmp[1:]) _ range(m) range m tmp = list(map(int,input().split())) tmp list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split s.append(tmp[1:]) s.append s append tmp[1:] tmp 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):
    for j in range(m):
        count = 0
        check = True
        for k in s[j]:
            if (i >> (k-1)) & 1:
                count += 1
        if count % 2 != p[j]:
            check = False
            break
    if check:
        ans += 1 i range(2**n) range 2**n 2 n for j in range(m):
        count = 0
        check = True
        for k in s[j]:
            if (i >> (k-1)) & 1:
                count += 1
        if count % 2 != p[j]:
            check = False
            break
     j range(m) range m count = 0 count 0 check = True check True for k in s[j]:
            if (i >> (k-1)) & 1:
                count += 1
         k s[j] s j if (i >> (k-1)) & 1:
                count += 1
         (i >> (k-1)) & 1 i >> (k-1) i k-1 k 1 1 count += 1 count 1 if count % 2 != p[j]:
            check = False
            break
     count % 2 != p[j] count % 2 count 2 p[j] p j check = False check False break if check:
        ans += 1 check ans += 1 ans 1 print(ans) print ans count = 0 0 count tmp = list(map(int,input().split())) list(map(int,input().split())) tmp n,m = map(int,input().split()) map(int,input().split()) n p = list(map(int,input().split())) list(map(int,input().split())) p s = [] [] s ans += 1 1 ans check = True True check count += 1 1 count m = map(int,input().split()) map(int,input().split()) m ans = 0 0 ans check = False False check
n,m = map(int,input().split())
s = []
for _ in range(m):
    tmp = list(map(int,input().split()))
    s.append(tmp[1:])
p = list(map(int,input().split()))

ans = 0
for i in range(2**n):
    for j in range(m):
        count = 0
        check = True
        for k in s[j]:
            if (i >> (k-1)) & 1:
                count += 1
        if count % 2 != p[j]:
            check = False
            break
    if check:
        ans += 1
print(ans)