def main():
    n, m = list(map(int, input().split(" ")))
    k_list = []
    s_list = []
    for _ in range(m):
        s = []
        for i, one in enumerate(input().split(" ")):
            if i==0:
                k = int(one)
            else:
                s.append(int(one))
        k_list.append(k)
        s_list.append(s)
    p = list(map(int, input().split(" ")))

    cnt = 0
    for x in range(2**n):
        f = 0
        onoff_list = [1 if bin(x)[2:].zfill(n)[i]=="1" else 0 for i in range(n)]
        for mi in range(m):
            s = s_list[mi]
            on_num = sum([onoff_list[si-1] for si in s])
            if on_num%2==p[mi]:
                f+=1
            else:
                break
        if f==m:
            cnt+=1
    print(cnt)

if __name__=="__main__":
    main() def main():
    n, m = list(map(int, input().split(" ")))
    k_list = []
    s_list = []
    for _ in range(m):
        s = []
        for i, one in enumerate(input().split(" ")):
            if i==0:
                k = int(one)
            else:
                s.append(int(one))
        k_list.append(k)
        s_list.append(s)
    p = list(map(int, input().split(" ")))

    cnt = 0
    for x in range(2**n):
        f = 0
        onoff_list = [1 if bin(x)[2:].zfill(n)[i]=="1" else 0 for i in range(n)]
        for mi in range(m):
            s = s_list[mi]
            on_num = sum([onoff_list[si-1] for si in s])
            if on_num%2==p[mi]:
                f+=1
            else:
                break
        if f==m:
            cnt+=1
    print(cnt) main n, m = list(map(int, input().split(" "))) n list(map(int, input().split(" "))) list map(int, input().split(" ")) map int input().split(" ") ().split () input split " " m k_list = [] k_list [] s_list = [] s_list [] for _ in range(m):
        s = []
        for i, one in enumerate(input().split(" ")):
            if i==0:
                k = int(one)
            else:
                s.append(int(one))
        k_list.append(k)
        s_list.append(s)
     _ range(m) range m s = [] s [] for i, one in enumerate(input().split(" ")):
            if i==0:
                k = int(one)
            else:
                s.append(int(one))
         i one enumerate(input().split(" ")) enumerate input().split(" ") ().split () input split " " if i==0:
                k = int(one)
            else:
                s.append(int(one))
         i==0 i 0 k = int(one) k int(one) int one s.append(int(one)) s.append s append int(one) int one k_list.append(k) k_list.append k_list append k s_list.append(s) s_list.append s_list append s p = list(map(int, input().split(" "))) p list(map(int, input().split(" "))) list map(int, input().split(" ")) map int input().split(" ") ().split () input split " " cnt = 0 cnt 0 for x in range(2**n):
        f = 0
        onoff_list = [1 if bin(x)[2:].zfill(n)[i]=="1" else 0 for i in range(n)]
        for mi in range(m):
            s = s_list[mi]
            on_num = sum([onoff_list[si-1] for si in s])
            if on_num%2==p[mi]:
                f+=1
            else:
                break
        if f==m:
            cnt+=1
     x range(2**n) range 2**n 2 n f = 0 f 0 1 if bin(x)[2:].zfill(n)[i]=="1" else 0 for i in range(n) for i in range(n) i range(n) range n for i in range(n) 1 if bin(x)[2:].zfill(n)[i]=="1" else 0 bin(x)[2:].zfill(n)[i]=="1" bin(x)[2:].zfill(n)[i] [2:].zfill(n) [2:].zfill [2:] (x) bin x 2: 2 zfill n i "1" 1 0 onoff_list = [1 if bin(x)[2:].zfill(n)[i]=="1" else 0 for i in range(n)] onoff_list [1 if bin(x)[2:].zfill(n)[i]=="1" else 0 for i in range(n)] for mi in range(m):
            s = s_list[mi]
            on_num = sum([onoff_list[si-1] for si in s])
            if on_num%2==p[mi]:
                f+=1
            else:
                break
         mi range(m) range m s = s_list[mi] s s_list[mi] s_list mi onoff_list[si-1] for si in s for si in s si s for si in s onoff_list[si-1] onoff_list si-1 si 1 on_num = sum([onoff_list[si-1] for si in s]) on_num sum([onoff_list[si-1] for si in s]) sum [onoff_list[si-1] for si in s] if on_num%2==p[mi]:
                f+=1
            else:
                break
         on_num%2==p[mi] on_num%2 on_num 2 p[mi] p mi f+=1 f 1 break if f==m:
            cnt+=1
     f==m f m cnt+=1 cnt 1 print(cnt) print cnt if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main def main():
    n, m = list(map(int, input().split(" ")))
    k_list = []
    s_list = []
    for _ in range(m):
        s = []
        for i, one in enumerate(input().split(" ")):
            if i==0:
                k = int(one)
            else:
                s.append(int(one))
        k_list.append(k)
        s_list.append(s)
    p = list(map(int, input().split(" ")))

    cnt = 0
    for x in range(2**n):
        f = 0
        onoff_list = [1 if bin(x)[2:].zfill(n)[i]=="1" else 0 for i in range(n)]
        for mi in range(m):
            s = s_list[mi]
            on_num = sum([onoff_list[si-1] for si in s])
            if on_num%2==p[mi]:
                f+=1
            else:
                break
        if f==m:
            cnt+=1
    print(cnt) def main():
    n, m = list(map(int, input().split(" ")))
    k_list = []
    s_list = []
    for _ in range(m):
        s = []
        for i, one in enumerate(input().split(" ")):
            if i==0:
                k = int(one)
            else:
                s.append(int(one))
        k_list.append(k)
        s_list.append(s)
    p = list(map(int, input().split(" ")))

    cnt = 0
    for x in range(2**n):
        f = 0
        onoff_list = [1 if bin(x)[2:].zfill(n)[i]=="1" else 0 for i in range(n)]
        for mi in range(m):
            s = s_list[mi]
            on_num = sum([onoff_list[si-1] for si in s])
            if on_num%2==p[mi]:
                f+=1
            else:
                break
        if f==m:
            cnt+=1
    print(cnt) main
def main():
    n, m = list(map(int, input().split(" ")))
    k_list = []
    s_list = []
    for _ in range(m):
        s = []
        for i, one in enumerate(input().split(" ")):
            if i==0:
                k = int(one)
            else:
                s.append(int(one))
        k_list.append(k)
        s_list.append(s)
    p = list(map(int, input().split(" ")))

    cnt = 0
    for x in range(2**n):
        f = 0
        onoff_list = [1 if bin(x)[2:].zfill(n)[i]=="1" else 0 for i in range(n)]
        for mi in range(m):
            s = s_list[mi]
            on_num = sum([onoff_list[si-1] for si in s])
            if on_num%2==p[mi]:
                f+=1
            else:
                break
        if f==m:
            cnt+=1
    print(cnt)

if __name__=="__main__":
    main()
