import sys
def read(): return sys.stdin.readline() # 標準入力
def fbit(i, j=-1): return format(i, 'b').zfill(j) # bit 表示
def popcount(x): # ビットカウント
    x=x-((x>>1)&0x5555555555555555)
    x=(x&0x3333333333333333)+((x>>2)&0x3333333333333333)
    x=(x+(x>>4))&0x0f0f0f0f0f0f0f0f;x=x+(x>>8);x=x+(x>>16);x=x+(x>>32)
    return x&0x0000007f


def solv(N:int, M: int, k:list, s: list, p: list):
    ans = 0
    for bits in range(1<<N):
        flag = True
        for i in range(M):
            mask = 0
            for j in s[i]:
                mask = mask|1<<(j-1)
            if not popcount(bits&mask)%2==p[i]: flag = False
        if flag: ans += 1
    print(ans)

def main():
    [N, M] = list(map(int, read().rsplit()))
    k = []; s = []
    for i in range(M):
        _tmp = list(map(int, read().rsplit()))
        k.append(_tmp.pop(0))
        s.append(_tmp)

    p = list(map(int, read().rsplit()))
    solv(N, M, k, s, p)


if __name__ == '__main__':
    main() import sys sys def read(): return sys.stdin.readline() # 標準入力 read def fbit(i, j=-1): return format(i, 'b').zfill(j) # bit 表示 fbit i i j=-1 j -1 def popcount(x): # ビットカウント
    x=x-((x>>1)&0x5555555555555555)
    x=(x&0x3333333333333333)+((x>>2)&0x3333333333333333)
    x=(x+(x>>4))&0x0f0f0f0f0f0f0f0f;x=x+(x>>8);x=x+(x>>16);x=x+(x>>32)
    return x&0x0000007f popcount x=x-((x>>1)&0x5555555555555555) x x-((x>>1)&0x5555555555555555) x (x>>1)&0x5555555555555555 x>>1 x 1 0x5555555555555555 x=(x&0x3333333333333333)+((x>>2)&0x3333333333333333) x (x&0x3333333333333333)+((x>>2)&0x3333333333333333) x&0x3333333333333333 x 0x3333333333333333 (x>>2)&0x3333333333333333 x>>2 x 2 0x3333333333333333 x=(x+(x>>4))&0x0f0f0f0f0f0f0f0f x (x+(x>>4))&0x0f0f0f0f0f0f0f0f x+(x>>4) x x>>4 x 4 0x0f0f0f0f0f0f0f0f x=x+(x>>8) x x+(x>>8) x x>>8 x 8 x=x+(x>>16) x x+(x>>16) x x>>16 x 16 x=x+(x>>32) x x+(x>>32) x x>>32 x 32 return x&0x0000007f x&0x0000007f x 0x0000007f x x def solv(N:int, M: int, k:list, s: list, p: list):
    ans = 0
    for bits in range(1<<N):
        flag = True
        for i in range(M):
            mask = 0
            for j in s[i]:
                mask = mask|1<<(j-1)
            if not popcount(bits&mask)%2==p[i]: flag = False
        if flag: ans += 1
    print(ans) solv ans = 0 ans 0 for bits in range(1<<N):
        flag = True
        for i in range(M):
            mask = 0
            for j in s[i]:
                mask = mask|1<<(j-1)
            if not popcount(bits&mask)%2==p[i]: flag = False
        if flag: ans += 1
     bits range(1<<N) range 1<<N 1 N flag = True flag True for i in range(M):
            mask = 0
            for j in s[i]:
                mask = mask|1<<(j-1)
            if not popcount(bits&mask)%2==p[i]: flag = False
         i range(M) range M mask = 0 mask 0 for j in s[i]:
                mask = mask|1<<(j-1)
             j s[i] s i mask = mask|1<<(j-1) mask mask|1<<(j-1) mask 1<<(j-1) 1 j-1 j 1 if not popcount(bits&mask)%2==p[i]: flag = False
         not popcount(bits&mask)%2==p[i] popcount(bits&mask)%2==p[i] popcount(bits&mask)%2 popcount(bits&mask) popcount bits&mask bits mask 2 p[i] p i if flag: ans += 1
     flag print(ans) print ans N:int N M: int M k:list k s: list s p: list p def main():
    [N, M] = list(map(int, read().rsplit()))
    k = []; s = []
    for i in range(M):
        _tmp = list(map(int, read().rsplit()))
        k.append(_tmp.pop(0))
        s.append(_tmp)

    p = list(map(int, read().rsplit()))
    solv(N, M, k, s, p) main [N, M] = list(map(int, read().rsplit())) [N, M] N M list(map(int, read().rsplit())) list map(int, read().rsplit()) map int read().rsplit() ().rsplit () read rsplit k = [] k [] s = [] s [] for i in range(M):
        _tmp = list(map(int, read().rsplit()))
        k.append(_tmp.pop(0))
        s.append(_tmp)

     i range(M) range M _tmp = list(map(int, read().rsplit())) _tmp list(map(int, read().rsplit())) list map(int, read().rsplit()) map int read().rsplit() ().rsplit () read rsplit k.append(_tmp.pop(0)) k.append k append _tmp.pop(0) _tmp.pop _tmp pop 0 s.append(_tmp) s.append s append _tmp p = list(map(int, read().rsplit())) p list(map(int, read().rsplit())) list map(int, read().rsplit()) map int read().rsplit() ().rsplit () read rsplit solv(N, M, k, s, p) solv N M k s p if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    [N, M] = list(map(int, read().rsplit()))
    k = []; s = []
    for i in range(M):
        _tmp = list(map(int, read().rsplit()))
        k.append(_tmp.pop(0))
        s.append(_tmp)

    p = list(map(int, read().rsplit()))
    solv(N, M, k, s, p) def main():
    [N, M] = list(map(int, read().rsplit()))
    k = []; s = []
    for i in range(M):
        _tmp = list(map(int, read().rsplit()))
        k.append(_tmp.pop(0))
        s.append(_tmp)

    p = list(map(int, read().rsplit()))
    solv(N, M, k, s, p) main def read(): return sys.stdin.readline() # 標準入力 def read(): return sys.stdin.readline() # 標準入力 read def popcount(x): # ビットカウント
    x=x-((x>>1)&0x5555555555555555)
    x=(x&0x3333333333333333)+((x>>2)&0x3333333333333333)
    x=(x+(x>>4))&0x0f0f0f0f0f0f0f0f;x=x+(x>>8);x=x+(x>>16);x=x+(x>>32)
    return x&0x0000007f def popcount(x): # ビットカウント
    x=x-((x>>1)&0x5555555555555555)
    x=(x&0x3333333333333333)+((x>>2)&0x3333333333333333)
    x=(x+(x>>4))&0x0f0f0f0f0f0f0f0f;x=x+(x>>8);x=x+(x>>16);x=x+(x>>32)
    return x&0x0000007f popcount def fbit(i, j=-1): return format(i, 'b').zfill(j) # bit 表示 def fbit(i, j=-1): return format(i, 'b').zfill(j) # bit 表示 fbit def solv(N:int, M: int, k:list, s: list, p: list):
    ans = 0
    for bits in range(1<<N):
        flag = True
        for i in range(M):
            mask = 0
            for j in s[i]:
                mask = mask|1<<(j-1)
            if not popcount(bits&mask)%2==p[i]: flag = False
        if flag: ans += 1
    print(ans) def solv(N:int, M: int, k:list, s: list, p: list):
    ans = 0
    for bits in range(1<<N):
        flag = True
        for i in range(M):
            mask = 0
            for j in s[i]:
                mask = mask|1<<(j-1)
            if not popcount(bits&mask)%2==p[i]: flag = False
        if flag: ans += 1
    print(ans) solv
import sys
def read(): return sys.stdin.readline() # 標準入力
def fbit(i, j=-1): return format(i, 'b').zfill(j) # bit 表示
def popcount(x): # ビットカウント
    x=x-((x>>1)&0x5555555555555555)
    x=(x&0x3333333333333333)+((x>>2)&0x3333333333333333)
    x=(x+(x>>4))&0x0f0f0f0f0f0f0f0f;x=x+(x>>8);x=x+(x>>16);x=x+(x>>32)
    return x&0x0000007f


def solv(N:int, M: int, k:list, s: list, p: list):
    ans = 0
    for bits in range(1<<N):
        flag = True
        for i in range(M):
            mask = 0
            for j in s[i]:
                mask = mask|1<<(j-1)
            if not popcount(bits&mask)%2==p[i]: flag = False
        if flag: ans += 1
    print(ans)

def main():
    [N, M] = list(map(int, read().rsplit()))
    k = []; s = []
    for i in range(M):
        _tmp = list(map(int, read().rsplit()))
        k.append(_tmp.pop(0))
        s.append(_tmp)

    p = list(map(int, read().rsplit()))
    solv(N, M, k, s, p)


if __name__ == '__main__':
    main()