n, m = map(int, input().split())
kk = []
ss = []
for i in range(m):
    ks = list(map(int, input().split()))
    k = ks[0]
    s = ks[1:]
    kk.append(k)
    ss.append(s)
p = list(map(int, input().split()))
ans = 0

for i in range(2 ** (n)):
    check = [0 for i in range(m)]
    for j in range(n):
        if i >> j & 1:
            for l in range(m):
                if (j + 1) in ss[l]:
                    check[l] = (check[l] + 1) % 2
    if check == p:
        ans += 1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m kk = [] kk [] ss = [] ss [] for i in range(m):
    ks = list(map(int, input().split()))
    k = ks[0]
    s = ks[1:]
    kk.append(k)
    ss.append(s) 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 k = ks[0] k ks[0] ks 0 s = ks[1:] s ks[1:] ks 1: 1 kk.append(k) kk.append kk append k ss.append(s) ss.append ss 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(2 ** (n)):
    check = [0 for i in range(m)]
    for j in range(n):
        if i >> j & 1:
            for l in range(m):
                if (j + 1) in ss[l]:
                    check[l] = (check[l] + 1) % 2
    if check == p:
        ans += 1 i range(2 ** (n)) range 2 ** (n) 2 n 0 for i in range(m) for i in range(m) i range(m) range m for i in range(m) 0 check = [0 for i in range(m)] check [0 for i in range(m)] for j in range(n):
        if i >> j & 1:
            for l in range(m):
                if (j + 1) in ss[l]:
                    check[l] = (check[l] + 1) % 2
     j range(n) range n if i >> j & 1:
            for l in range(m):
                if (j + 1) in ss[l]:
                    check[l] = (check[l] + 1) % 2
     i >> j & 1 i >> j i j 1 for l in range(m):
                if (j + 1) in ss[l]:
                    check[l] = (check[l] + 1) % 2
     l range(m) range m if (j + 1) in ss[l]:
                    check[l] = (check[l] + 1) % 2
     (j + 1) in ss[l] j + 1 j 1 ss[l] ss l check[l] = (check[l] + 1) % 2 check[l] check l (check[l] + 1) % 2 check[l] + 1 check[l] check l 1 2 if check == p:
        ans += 1 check == p check p ans += 1 ans 1 print(ans) print ans ans = 0 0 ans ans += 1 1 ans n, m = map(int, input().split()) map(int, input().split()) n ks = list(map(int, input().split())) list(map(int, input().split())) ks m = map(int, input().split()) map(int, input().split()) m s = ks[1:] ks[1:] s k = ks[0] ks[0] k kk = [] [] kk check = [0 for i in range(m)] [0 for i in range(m)] check p = list(map(int, input().split())) list(map(int, input().split())) p ss = [] [] ss
n, m = map(int, input().split())
kk = []
ss = []
for i in range(m):
    ks = list(map(int, input().split()))
    k = ks[0]
    s = ks[1:]
    kk.append(k)
    ss.append(s)
p = list(map(int, input().split()))
ans = 0

for i in range(2 ** (n)):
    check = [0 for i in range(m)]
    for j in range(n):
        if i >> j & 1:
            for l in range(m):
                if (j + 1) in ss[l]:
                    check[l] = (check[l] + 1) % 2
    if check == p:
        ans += 1
print(ans)
