def main():
    import itertools
    n,m = map(int,input().split())
    lt = []
    for i in range(m):
        lt.append(list(map(int,input().split())))
    p = list(map(int,input().split()))
    stats = ((0,1) for i in range(n))
    ans = 0
    for stat in itertools.product(*stats):
        flg = 0
        for i in range(m):
            cnt = 0
            for j in range(1,lt[i][0]+1):
                if stat[lt[i][j]-1]==1:
                    cnt+=1
            if cnt%2!=p[i]:
                flg = 1
                break
        if flg==0:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main() def main():
    import itertools
    n,m = map(int,input().split())
    lt = []
    for i in range(m):
        lt.append(list(map(int,input().split())))
    p = list(map(int,input().split()))
    stats = ((0,1) for i in range(n))
    ans = 0
    for stat in itertools.product(*stats):
        flg = 0
        for i in range(m):
            cnt = 0
            for j in range(1,lt[i][0]+1):
                if stat[lt[i][j]-1]==1:
                    cnt+=1
            if cnt%2!=p[i]:
                flg = 1
                break
        if flg==0:
            ans += 1
    print(ans) main import itertools itertools n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m lt = [] lt [] for i in range(m):
        lt.append(list(map(int,input().split())))
     i range(m) range m lt.append(list(map(int,input().split()))) lt.append lt append list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split p = list(map(int,input().split())) p list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split (0,1) for i in range(n) for i in range(n) i range(n) range n for i in range(n) (0,1) 0 1 stats = ((0,1) for i in range(n)) stats ((0,1) for i in range(n)) ans = 0 ans 0 for stat in itertools.product(*stats):
        flg = 0
        for i in range(m):
            cnt = 0
            for j in range(1,lt[i][0]+1):
                if stat[lt[i][j]-1]==1:
                    cnt+=1
            if cnt%2!=p[i]:
                flg = 1
                break
        if flg==0:
            ans += 1
     stat itertools.product(*stats) itertools.product itertools product *stats stats flg = 0 flg 0 for i in range(m):
            cnt = 0
            for j in range(1,lt[i][0]+1):
                if stat[lt[i][j]-1]==1:
                    cnt+=1
            if cnt%2!=p[i]:
                flg = 1
                break
         i range(m) range m cnt = 0 cnt 0 for j in range(1,lt[i][0]+1):
                if stat[lt[i][j]-1]==1:
                    cnt+=1
             j range(1,lt[i][0]+1) range 1 lt[i][0]+1 lt[i][0] [i] lt i 0 1 if stat[lt[i][j]-1]==1:
                    cnt+=1
             stat[lt[i][j]-1]==1 stat[lt[i][j]-1] stat lt[i][j]-1 lt[i][j] [i] lt i j 1 1 cnt+=1 cnt 1 if cnt%2!=p[i]:
                flg = 1
                break
         cnt%2!=p[i] cnt%2 cnt 2 p[i] p i flg = 1 flg 1 break if flg==0:
            ans += 1
     flg==0 flg 0 ans += 1 ans 1 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    import itertools
    n,m = map(int,input().split())
    lt = []
    for i in range(m):
        lt.append(list(map(int,input().split())))
    p = list(map(int,input().split()))
    stats = ((0,1) for i in range(n))
    ans = 0
    for stat in itertools.product(*stats):
        flg = 0
        for i in range(m):
            cnt = 0
            for j in range(1,lt[i][0]+1):
                if stat[lt[i][j]-1]==1:
                    cnt+=1
            if cnt%2!=p[i]:
                flg = 1
                break
        if flg==0:
            ans += 1
    print(ans) def main():
    import itertools
    n,m = map(int,input().split())
    lt = []
    for i in range(m):
        lt.append(list(map(int,input().split())))
    p = list(map(int,input().split()))
    stats = ((0,1) for i in range(n))
    ans = 0
    for stat in itertools.product(*stats):
        flg = 0
        for i in range(m):
            cnt = 0
            for j in range(1,lt[i][0]+1):
                if stat[lt[i][j]-1]==1:
                    cnt+=1
            if cnt%2!=p[i]:
                flg = 1
                break
        if flg==0:
            ans += 1
    print(ans) main
def main():
    import itertools
    n,m = map(int,input().split())
    lt = []
    for i in range(m):
        lt.append(list(map(int,input().split())))
    p = list(map(int,input().split()))
    stats = ((0,1) for i in range(n))
    ans = 0
    for stat in itertools.product(*stats):
        flg = 0
        for i in range(m):
            cnt = 0
            for j in range(1,lt[i][0]+1):
                if stat[lt[i][j]-1]==1:
                    cnt+=1
            if cnt%2!=p[i]:
                flg = 1
                break
        if flg==0:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()
