from itertools import combinations

def getval():
    n,m = map(int,input().split())
    s = [list(map(int,input().split())) for i in range(m)]
    for i in range(m):
        for j in range(1,s[i][0]+1):
            s[i][j] -= 1
    p = list(map(int,input().split()))
    return n,m,s,p 

def main(n,m,s,p):
    l = [[] for i in range(n)]
    for i in range(m):
        for j in range(1,s[i][0]+1):
            l[s[i][j]].append(i)
    ans = 0
    for i in range(n+1):
        for c in combinations(range(n),i):
            temp = [0 for i in range(m)]
            for j in c:
                for k in l[j]:
                    temp[k] += 1
                    temp[k] %= 2
            if temp==p:
                ans += 1
    print(ans)

if __name__=="__main__":
    n,m,s,p = getval()
    main(n,m,s,p) from itertools import combinations def getval():
    n,m = map(int,input().split())
    s = [list(map(int,input().split())) for i in range(m)]
    for i in range(m):
        for j in range(1,s[i][0]+1):
            s[i][j] -= 1
    p = list(map(int,input().split()))
    return n,m,s,p  getval n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m list(map(int,input().split())) for i in range(m) for i in range(m) i range(m) range m for i in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split s = [list(map(int,input().split())) for i in range(m)] s [list(map(int,input().split())) for i in range(m)] for i in range(m):
        for j in range(1,s[i][0]+1):
            s[i][j] -= 1
     i range(m) range m for j in range(1,s[i][0]+1):
            s[i][j] -= 1
     j range(1,s[i][0]+1) range 1 s[i][0]+1 s[i][0] [i] s i 0 1 s[i][j] -= 1 s[i][j] [i] s i j 1 p = list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split return n,m,s,p return n,m,s,p n m s p def main(n,m,s,p):
    l = [[] for i in range(n)]
    for i in range(m):
        for j in range(1,s[i][0]+1):
            l[s[i][j]].append(i)
    ans = 0
    for i in range(n+1):
        for c in combinations(range(n),i):
            temp = [0 for i in range(m)]
            for j in c:
                for k in l[j]:
                    temp[k] += 1
                    temp[k] %= 2
            if temp==p:
                ans += 1
    print(ans) main [] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [] l = [[] for i in range(n)] l [[] for i in range(n)] for i in range(m):
        for j in range(1,s[i][0]+1):
            l[s[i][j]].append(i)
     i range(m) range m for j in range(1,s[i][0]+1):
            l[s[i][j]].append(i)
     j range(1,s[i][0]+1) range 1 s[i][0]+1 s[i][0] [i] s i 0 1 l[s[i][j]].append(i) [s[i][j]].append [s[i][j]] l s[i][j] [i] s i j append i ans = 0 ans 0 for i in range(n+1):
        for c in combinations(range(n),i):
            temp = [0 for i in range(m)]
            for j in c:
                for k in l[j]:
                    temp[k] += 1
                    temp[k] %= 2
            if temp==p:
                ans += 1
     i range(n+1) range n+1 n 1 for c in combinations(range(n),i):
            temp = [0 for i in range(m)]
            for j in c:
                for k in l[j]:
                    temp[k] += 1
                    temp[k] %= 2
            if temp==p:
                ans += 1
     c combinations(range(n),i) combinations range(n) range n i 0 for i in range(m) for i in range(m) i range(m) range m for i in range(m) 0 temp = [0 for i in range(m)] temp [0 for i in range(m)] for j in c:
                for k in l[j]:
                    temp[k] += 1
                    temp[k] %= 2
             j c for k in l[j]:
                    temp[k] += 1
                    temp[k] %= 2
             k l[j] l j temp[k] += 1 temp[k] temp k 1 temp[k] %= 2 temp[k] temp k 2 if temp==p:
                ans += 1
     temp==p temp p ans += 1 ans 1 print(ans) print ans n n m m s s p p if __name__=="__main__":
    n,m,s,p = getval()
    main(n,m,s,p) __name__=="__main__" __name__ "__main__" n,m,s,p = getval() n getval() getval m s p main(n,m,s,p) main n m s p m,s,p = getval() getval() m def getval():
    n,m = map(int,input().split())
    s = [list(map(int,input().split())) for i in range(m)]
    for i in range(m):
        for j in range(1,s[i][0]+1):
            s[i][j] -= 1
    p = list(map(int,input().split()))
    return n,m,s,p  def getval():
    n,m = map(int,input().split())
    s = [list(map(int,input().split())) for i in range(m)]
    for i in range(m):
        for j in range(1,s[i][0]+1):
            s[i][j] -= 1
    p = list(map(int,input().split()))
    return n,m,s,p  getval p = getval() getval() p s,p = getval() getval() s n,m,s,p = getval() getval() n def main(n,m,s,p):
    l = [[] for i in range(n)]
    for i in range(m):
        for j in range(1,s[i][0]+1):
            l[s[i][j]].append(i)
    ans = 0
    for i in range(n+1):
        for c in combinations(range(n),i):
            temp = [0 for i in range(m)]
            for j in c:
                for k in l[j]:
                    temp[k] += 1
                    temp[k] %= 2
            if temp==p:
                ans += 1
    print(ans) def main(n,m,s,p):
    l = [[] for i in range(n)]
    for i in range(m):
        for j in range(1,s[i][0]+1):
            l[s[i][j]].append(i)
    ans = 0
    for i in range(n+1):
        for c in combinations(range(n),i):
            temp = [0 for i in range(m)]
            for j in c:
                for k in l[j]:
                    temp[k] += 1
                    temp[k] %= 2
            if temp==p:
                ans += 1
    print(ans) main
from itertools import combinations

def getval():
    n,m = map(int,input().split())
    s = [list(map(int,input().split())) for i in range(m)]
    for i in range(m):
        for j in range(1,s[i][0]+1):
            s[i][j] -= 1
    p = list(map(int,input().split()))
    return n,m,s,p 

def main(n,m,s,p):
    l = [[] for i in range(n)]
    for i in range(m):
        for j in range(1,s[i][0]+1):
            l[s[i][j]].append(i)
    ans = 0
    for i in range(n+1):
        for c in combinations(range(n),i):
            temp = [0 for i in range(m)]
            for j in c:
                for k in l[j]:
                    temp[k] += 1
                    temp[k] %= 2
            if temp==p:
                ans += 1
    print(ans)

if __name__=="__main__":
    n,m,s,p = getval()
    main(n,m,s,p)