#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    SW = [list(map(int, input().split()))[1:] for _ in range(M)]
    P = list(map(int, input().split()))

    num = 0
    for i in range(2**N+1):
        ng = False
        for j, sw in enumerate(SW):
            n = 0
            for k in sw:
                if i & 2**(k-1):
                    n = n + 1
            if n%2 != P[j]:
                ng = True
                break
        else:
            num = num + 1
    
    print(num)



# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc128","c",main)