#m = int(input())
n, m = map(int, input().split())
#al = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]
switch = []
kl = []
for i in range(m):
    temp = list(map(int, input().split()))
    kl.append(temp[0])
    switch.append(temp[1:])
pl = list(map(int, input().split()))
# print(switch)

pattern = [[0 for _ in range(n)] for _1 in range(2**n)]
for i in range(2**n):
    for j in range(n):
        if ((i >> j) & 1):  # 二進数iの下から数えてj桁目が1か否か
            pattern[i][j] = 1

ans = 0
for ptnum, spt in enumerate(pattern):
    islit = True
    for lightnum in range(m):
        count = 0
        for s in switch[lightnum]:
            if spt[s-1] == 1:
                count += 1
        if count % 2 != pl[lightnum]:
            islit = False
            break
    if islit:
        ans += 1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m switch = [] switch [] kl = [] kl [] for i in range(m):
    temp = list(map(int, input().split()))
    kl.append(temp[0])
    switch.append(temp[1:]) i range(m) range m temp = list(map(int, input().split())) temp list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split kl.append(temp[0]) kl.append kl append temp[0] temp 0 switch.append(temp[1:]) switch.append switch append temp[1:] temp 1: 1 pl = list(map(int, input().split())) pl list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split [0 for _ in range(n)] for _1 in range(2**n) for _1 in range(2**n) _1 range(2**n) range 2**n 2 n for _1 in range(2**n) [0 for _ in range(n)] pattern = [[0 for _ in range(n)] for _1 in range(2**n)] pattern [[0 for _ in range(n)] for _1 in range(2**n)] for i in range(2**n):
    for j in range(n):
        if ((i >> j) & 1):  # 二進数iの下から数えてj桁目が1か否か
            pattern[i][j] = 1 i range(2**n) range 2**n 2 n for j in range(n):
        if ((i >> j) & 1):  # 二進数iの下から数えてj桁目が1か否か
            pattern[i][j] = 1 j range(n) range n if ((i >> j) & 1):  # 二進数iの下から数えてj桁目が1か否か
            pattern[i][j] = 1 (i >> j) & 1 i >> j i j 1 pattern[i][j] = 1 pattern[i][j] [i] pattern i j 1 ans = 0 ans 0 for ptnum, spt in enumerate(pattern):
    islit = True
    for lightnum in range(m):
        count = 0
        for s in switch[lightnum]:
            if spt[s-1] == 1:
                count += 1
        if count % 2 != pl[lightnum]:
            islit = False
            break
    if islit:
        ans += 1 ptnum spt enumerate(pattern) enumerate pattern islit = True islit True for lightnum in range(m):
        count = 0
        for s in switch[lightnum]:
            if spt[s-1] == 1:
                count += 1
        if count % 2 != pl[lightnum]:
            islit = False
            break
     lightnum range(m) range m count = 0 count 0 for s in switch[lightnum]:
            if spt[s-1] == 1:
                count += 1
         s switch[lightnum] switch lightnum if spt[s-1] == 1:
                count += 1
         spt[s-1] == 1 spt[s-1] spt s-1 s 1 1 count += 1 count 1 if count % 2 != pl[lightnum]:
            islit = False
            break
     count % 2 != pl[lightnum] count % 2 count 2 pl[lightnum] pl lightnum islit = False islit False break if islit:
        ans += 1 islit ans += 1 ans 1 print(ans) print ans ans = 0 0 ans islit = True True islit switch = [] [] switch pl = list(map(int, input().split())) list(map(int, input().split())) pl count = 0 0 count kl = [] [] kl m = map(int, input().split()) map(int, input().split()) m pattern = [[0 for _ in range(n)] for _1 in range(2**n)] [[0 for _ in range(n)] for _1 in range(2**n)] pattern temp = list(map(int, input().split())) list(map(int, input().split())) temp n, m = map(int, input().split()) map(int, input().split()) n count += 1 1 count islit = False False islit ans += 1 1 ans
#m = int(input())
n, m = map(int, input().split())
#al = list(map(int, input().split()))
#al=[list(input()) for i in range(n)]
switch = []
kl = []
for i in range(m):
    temp = list(map(int, input().split()))
    kl.append(temp[0])
    switch.append(temp[1:])
pl = list(map(int, input().split()))
# print(switch)

pattern = [[0 for _ in range(n)] for _1 in range(2**n)]
for i in range(2**n):
    for j in range(n):
        if ((i >> j) & 1):  # 二進数iの下から数えてj桁目が1か否か
            pattern[i][j] = 1

ans = 0
for ptnum, spt in enumerate(pattern):
    islit = True
    for lightnum in range(m):
        count = 0
        for s in switch[lightnum]:
            if spt[s-1] == 1:
                count += 1
        if count % 2 != pl[lightnum]:
            islit = False
            break
    if islit:
        ans += 1
print(ans)
