n, m = map(int, input().split())
sl = []
for i in range(m):
    s = list(map(int, input().split()))
    del s[0]
    sl.append(s)
p = list(map(int, input().split()))

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

ans = 0
for i in range(1 << n):
    ok = True
    for j in range(m):
        cnt = 0
        for k in range(len(sl[j])):
            if (i >> sl[j][k] - 1)%2 == 0:
                cnt += 1
        if cnt%2 != p[j]:
            ok = False
            break
    if ok:
        ans += 1
print(ans)