#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-30 02:44:47 +0900
# LastModified: 2020-07-30 13:58:47 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, m = map(int, input().split())
    switch_list = []
    for _ in range(m):
        command = list(map(int, input().split()))
        _ = command[0]
        switch_list.append(command[1:])
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1 << n):
        flag = 1
        for j, switch in enumerate(switch_list):
            cnt = 0
            for s in switch:
                if 1 & i >> (s-1):
                    cnt += 1
            if cnt % 2 != p[j]:
                flag = 0
                break
        if flag == 1:
            ans += 1

    print(ans)






if __name__ == "__main__":
    main() import os os import sys sys def main():
    n, m = map(int, input().split())
    switch_list = []
    for _ in range(m):
        command = list(map(int, input().split()))
        _ = command[0]
        switch_list.append(command[1:])
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1 << n):
        flag = 1
        for j, switch in enumerate(switch_list):
            cnt = 0
            for s in switch:
                if 1 & i >> (s-1):
                    cnt += 1
            if cnt % 2 != p[j]:
                flag = 0
                break
        if flag == 1:
            ans += 1

    print(ans) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m switch_list = [] switch_list [] for _ in range(m):
        command = list(map(int, input().split()))
        _ = command[0]
        switch_list.append(command[1:])
     _ range(m) range m command = list(map(int, input().split())) command list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split _ = command[0] _ command[0] command 0 switch_list.append(command[1:]) switch_list.append switch_list append command[1:] command 1: 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 ans = 0 ans 0 for i in range(1 << n):
        flag = 1
        for j, switch in enumerate(switch_list):
            cnt = 0
            for s in switch:
                if 1 & i >> (s-1):
                    cnt += 1
            if cnt % 2 != p[j]:
                flag = 0
                break
        if flag == 1:
            ans += 1

     i range(1 << n) range 1 << n 1 n flag = 1 flag 1 for j, switch in enumerate(switch_list):
            cnt = 0
            for s in switch:
                if 1 & i >> (s-1):
                    cnt += 1
            if cnt % 2 != p[j]:
                flag = 0
                break
         j switch enumerate(switch_list) enumerate switch_list cnt = 0 cnt 0 for s in switch:
                if 1 & i >> (s-1):
                    cnt += 1
             s switch if 1 & i >> (s-1):
                    cnt += 1
             1 & i >> (s-1) 1 i >> (s-1) i s-1 s 1 cnt += 1 cnt 1 if cnt % 2 != p[j]:
                flag = 0
                break
         cnt % 2 != p[j] cnt % 2 cnt 2 p[j] p j flag = 0 flag 0 break if flag == 1:
            ans += 1

     flag == 1 flag 1 ans += 1 ans 1 print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n, m = map(int, input().split())
    switch_list = []
    for _ in range(m):
        command = list(map(int, input().split()))
        _ = command[0]
        switch_list.append(command[1:])
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1 << n):
        flag = 1
        for j, switch in enumerate(switch_list):
            cnt = 0
            for s in switch:
                if 1 & i >> (s-1):
                    cnt += 1
            if cnt % 2 != p[j]:
                flag = 0
                break
        if flag == 1:
            ans += 1

    print(ans) def main():
    n, m = map(int, input().split())
    switch_list = []
    for _ in range(m):
        command = list(map(int, input().split()))
        _ = command[0]
        switch_list.append(command[1:])
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1 << n):
        flag = 1
        for j, switch in enumerate(switch_list):
            cnt = 0
            for s in switch:
                if 1 & i >> (s-1):
                    cnt += 1
            if cnt % 2 != p[j]:
                flag = 0
                break
        if flag == 1:
            ans += 1

    print(ans) main
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-30 02:44:47 +0900
# LastModified: 2020-07-30 13:58:47 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, m = map(int, input().split())
    switch_list = []
    for _ in range(m):
        command = list(map(int, input().split()))
        _ = command[0]
        switch_list.append(command[1:])
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1 << n):
        flag = 1
        for j, switch in enumerate(switch_list):
            cnt = 0
            for s in switch:
                if 1 & i >> (s-1):
                    cnt += 1
            if cnt % 2 != p[j]:
                flag = 0
                break
        if flag == 1:
            ans += 1

    print(ans)






if __name__ == "__main__":
    main()
