import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    n,m = LI()
    s = [[] for i in range(n)]
    ans = 0
    for i in range(1,m+1):
        lst = LI()
        for j in lst[1:]:
            s[j-1].append(i)
    p = [0] + LI()
    # print(n,m,s,p)
    bits = itertools.product([0,1],repeat=n)
    for bit in bits:
        lst = [0 for _ in range(m+1)]
        for i in range(n):
            if bit[i] == 1:
                for j in s[i]:
                    lst[j] = not lst[j]
        if lst == p:
            ans+= 1
    print(ans)
main() import bisect,collections,copy,itertools,math,string bisect collections copy itertools math string import sys sys def I(): return int(sys.stdin.readline().rstrip()) I def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI def S(): return sys.stdin.readline().rstrip() S def LS(): return list(sys.stdin.readline().rstrip.split()) LS def main():
    n,m = LI()
    s = [[] for i in range(n)]
    ans = 0
    for i in range(1,m+1):
        lst = LI()
        for j in lst[1:]:
            s[j-1].append(i)
    p = [0] + LI()
    # print(n,m,s,p)
    bits = itertools.product([0,1],repeat=n)
    for bit in bits:
        lst = [0 for _ in range(m+1)]
        for i in range(n):
            if bit[i] == 1:
                for j in s[i]:
                    lst[j] = not lst[j]
        if lst == p:
            ans+= 1
    print(ans) main n,m = LI() n LI() LI m [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] s = [[] for i in range(n)] s [[] for i in range(n)] ans = 0 ans 0 for i in range(1,m+1):
        lst = LI()
        for j in lst[1:]:
            s[j-1].append(i)
     i range(1,m+1) range 1 m+1 m 1 lst = LI() lst LI() LI for j in lst[1:]:
            s[j-1].append(i)
     j lst[1:] lst 1: 1 s[j-1].append(i) [j-1].append [j-1] s j-1 j 1 append i p = [0] + LI() p [0] + LI() [0] 0 LI() LI bits = itertools.product([0,1],repeat=n) bits itertools.product([0,1],repeat=n) itertools.product itertools product [0,1] 0 1 repeat=n repeat n for bit in bits:
        lst = [0 for _ in range(m+1)]
        for i in range(n):
            if bit[i] == 1:
                for j in s[i]:
                    lst[j] = not lst[j]
        if lst == p:
            ans+= 1
     bit bits 0 for _ in range(m+1) for _ in range(m+1) _ range(m+1) range m+1 m 1 for _ in range(m+1) 0 lst = [0 for _ in range(m+1)] lst [0 for _ in range(m+1)] for i in range(n):
            if bit[i] == 1:
                for j in s[i]:
                    lst[j] = not lst[j]
         i range(n) range n if bit[i] == 1:
                for j in s[i]:
                    lst[j] = not lst[j]
         bit[i] == 1 bit[i] bit i 1 for j in s[i]:
                    lst[j] = not lst[j]
         j s[i] s i lst[j] = not lst[j] lst[j] lst j not lst[j] lst[j] lst j if lst == p:
            ans+= 1
     lst == p lst p ans+= 1 ans 1 print(ans) print ans main() main def S(): return sys.stdin.readline().rstrip() def S(): return sys.stdin.readline().rstrip() S def main():
    n,m = LI()
    s = [[] for i in range(n)]
    ans = 0
    for i in range(1,m+1):
        lst = LI()
        for j in lst[1:]:
            s[j-1].append(i)
    p = [0] + LI()
    # print(n,m,s,p)
    bits = itertools.product([0,1],repeat=n)
    for bit in bits:
        lst = [0 for _ in range(m+1)]
        for i in range(n):
            if bit[i] == 1:
                for j in s[i]:
                    lst[j] = not lst[j]
        if lst == p:
            ans+= 1
    print(ans) def main():
    n,m = LI()
    s = [[] for i in range(n)]
    ans = 0
    for i in range(1,m+1):
        lst = LI()
        for j in lst[1:]:
            s[j-1].append(i)
    p = [0] + LI()
    # print(n,m,s,p)
    bits = itertools.product([0,1],repeat=n)
    for bit in bits:
        lst = [0 for _ in range(m+1)]
        for i in range(n):
            if bit[i] == 1:
                for j in s[i]:
                    lst[j] = not lst[j]
        if lst == p:
            ans+= 1
    print(ans) main def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI def I(): return int(sys.stdin.readline().rstrip()) def I(): return int(sys.stdin.readline().rstrip()) I def LS(): return list(sys.stdin.readline().rstrip.split()) def LS(): return list(sys.stdin.readline().rstrip.split()) LS
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    n,m = LI()
    s = [[] for i in range(n)]
    ans = 0
    for i in range(1,m+1):
        lst = LI()
        for j in lst[1:]:
            s[j-1].append(i)
    p = [0] + LI()
    # print(n,m,s,p)
    bits = itertools.product([0,1],repeat=n)
    for bit in bits:
        lst = [0 for _ in range(m+1)]
        for i in range(n):
            if bit[i] == 1:
                for j in s[i]:
                    lst[j] = not lst[j]
        if lst == p:
            ans+= 1
    print(ans)
main()