#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, m = MI()
    connected = []
    for i in range(m):
        row = LI()
        swithes = row[1:]
        connected.append(swithes)
    p = LI()
    ans = 0
    for i in range(2 ** n):
        i_str = format(i, f"0{n}b")
        is_ok = True
        for m_idx in range(m):
            sum_1 = 0
            for swith in connected[m_idx]:
                if i_str[swith - 1] == "1":
                    sum_1 += 1

            if sum_1 % 2 != p[m_idx]:
                is_ok = False
                break

        if is_ok:
            ans += 1

    print(ans)


main() import collections as cl collections import sys sys def II():
    return int(sys.stdin.readline()) II return int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline def MI():
    return map(int, sys.stdin.readline().split()) MI return map(int, sys.stdin.readline().split()) map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split def LI():
    return list(map(int, sys.stdin.readline().split())) LI return list(map(int, sys.stdin.readline().split())) list(map(int, sys.stdin.readline().split())) list map(int, sys.stdin.readline().split()) map int sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split def main():
    n, m = MI()
    connected = []
    for i in range(m):
        row = LI()
        swithes = row[1:]
        connected.append(swithes)
    p = LI()
    ans = 0
    for i in range(2 ** n):
        i_str = format(i, f"0{n}b")
        is_ok = True
        for m_idx in range(m):
            sum_1 = 0
            for swith in connected[m_idx]:
                if i_str[swith - 1] == "1":
                    sum_1 += 1

            if sum_1 % 2 != p[m_idx]:
                is_ok = False
                break

        if is_ok:
            ans += 1

    print(ans) main n, m = MI() n MI() MI m connected = [] connected [] for i in range(m):
        row = LI()
        swithes = row[1:]
        connected.append(swithes)
     i range(m) range m row = LI() row LI() LI swithes = row[1:] swithes row[1:] row 1: 1 connected.append(swithes) connected.append connected append swithes p = LI() p LI() LI ans = 0 ans 0 for i in range(2 ** n):
        i_str = format(i, f"0{n}b")
        is_ok = True
        for m_idx in range(m):
            sum_1 = 0
            for swith in connected[m_idx]:
                if i_str[swith - 1] == "1":
                    sum_1 += 1

            if sum_1 % 2 != p[m_idx]:
                is_ok = False
                break

        if is_ok:
            ans += 1

     i range(2 ** n) range 2 ** n 2 n i_str = format(i, f"0{n}b") i_str format(i, f"0{n}b") format i f"0{n}b" is_ok = True is_ok True for m_idx in range(m):
            sum_1 = 0
            for swith in connected[m_idx]:
                if i_str[swith - 1] == "1":
                    sum_1 += 1

            if sum_1 % 2 != p[m_idx]:
                is_ok = False
                break

         m_idx range(m) range m sum_1 = 0 sum_1 0 for swith in connected[m_idx]:
                if i_str[swith - 1] == "1":
                    sum_1 += 1

             swith connected[m_idx] connected m_idx if i_str[swith - 1] == "1":
                    sum_1 += 1

             i_str[swith - 1] == "1" i_str[swith - 1] i_str swith - 1 swith 1 "1" sum_1 += 1 sum_1 1 if sum_1 % 2 != p[m_idx]:
                is_ok = False
                break

         sum_1 % 2 != p[m_idx] sum_1 % 2 sum_1 2 p[m_idx] p m_idx is_ok = False is_ok False break if is_ok:
            ans += 1

     is_ok ans += 1 ans 1 print(ans) print ans main() main def LI():
    return list(map(int, sys.stdin.readline().split())) def LI():
    return list(map(int, sys.stdin.readline().split())) LI def II():
    return int(sys.stdin.readline()) def II():
    return int(sys.stdin.readline()) II def main():
    n, m = MI()
    connected = []
    for i in range(m):
        row = LI()
        swithes = row[1:]
        connected.append(swithes)
    p = LI()
    ans = 0
    for i in range(2 ** n):
        i_str = format(i, f"0{n}b")
        is_ok = True
        for m_idx in range(m):
            sum_1 = 0
            for swith in connected[m_idx]:
                if i_str[swith - 1] == "1":
                    sum_1 += 1

            if sum_1 % 2 != p[m_idx]:
                is_ok = False
                break

        if is_ok:
            ans += 1

    print(ans) def main():
    n, m = MI()
    connected = []
    for i in range(m):
        row = LI()
        swithes = row[1:]
        connected.append(swithes)
    p = LI()
    ans = 0
    for i in range(2 ** n):
        i_str = format(i, f"0{n}b")
        is_ok = True
        for m_idx in range(m):
            sum_1 = 0
            for swith in connected[m_idx]:
                if i_str[swith - 1] == "1":
                    sum_1 += 1

            if sum_1 % 2 != p[m_idx]:
                is_ok = False
                break

        if is_ok:
            ans += 1

    print(ans) main def MI():
    return map(int, sys.stdin.readline().split()) def MI():
    return map(int, sys.stdin.readline().split()) MI
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, m = MI()
    connected = []
    for i in range(m):
        row = LI()
        swithes = row[1:]
        connected.append(swithes)
    p = LI()
    ans = 0
    for i in range(2 ** n):
        i_str = format(i, f"0{n}b")
        is_ok = True
        for m_idx in range(m):
            sum_1 = 0
            for swith in connected[m_idx]:
                if i_str[swith - 1] == "1":
                    sum_1 += 1

            if sum_1 % 2 != p[m_idx]:
                is_ok = False
                break

        if is_ok:
            ans += 1

    print(ans)


main()
