import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,M = map(int, input().split())
    RAMPS = [0]*M
    for i in range(M):
        tmp = list(map(int, input().split()))
        RAMPS[i] = [x-1 for x in tmp[1:]]
    PS = list(map(int, input().split()))
    ans = 0
    for bit in range(2**N+1):
        for i in range(M):
            cnt = 0
            for j in RAMPS[i]:
                if 1<<j & bit != 0: cnt += 1
            if cnt%2 != PS[i]:
                break
        else:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()