def resolve():
    import itertools
    N, M = map(int, input().split())
    S = []
    K = []
    ans = 0
    for _ in range(M):
        s = list(map(int, input().split()))
        K.append(s[0])
        S.append(s[1:])
    P = list(map(int, input().split()))
    for i in itertools.product([0,1], repeat=N):
        count = 0
        for j in range(M):
            ichi = 0
            for q in range(K[j]):
                ichi += i[S[j][q]-1]
            if ichi%2 == P[j]:
                count += 1
        if count == M:
            ans += 1
    print(ans)
resolve() def resolve():
    import itertools
    N, M = map(int, input().split())
    S = []
    K = []
    ans = 0
    for _ in range(M):
        s = list(map(int, input().split()))
        K.append(s[0])
        S.append(s[1:])
    P = list(map(int, input().split()))
    for i in itertools.product([0,1], repeat=N):
        count = 0
        for j in range(M):
            ichi = 0
            for q in range(K[j]):
                ichi += i[S[j][q]-1]
            if ichi%2 == P[j]:
                count += 1
        if count == M:
            ans += 1
    print(ans) resolve import itertools itertools N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M S = [] S [] K = [] K [] ans = 0 ans 0 for _ in range(M):
        s = list(map(int, input().split()))
        K.append(s[0])
        S.append(s[1:])
     _ range(M) range M s = list(map(int, input().split())) s list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split K.append(s[0]) K.append K append s[0] s 0 S.append(s[1:]) S.append S append s[1:] s 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 for i in itertools.product([0,1], repeat=N):
        count = 0
        for j in range(M):
            ichi = 0
            for q in range(K[j]):
                ichi += i[S[j][q]-1]
            if ichi%2 == P[j]:
                count += 1
        if count == M:
            ans += 1
     i itertools.product([0,1], repeat=N) itertools.product itertools product [0,1] 0 1 repeat=N repeat N count = 0 count 0 for j in range(M):
            ichi = 0
            for q in range(K[j]):
                ichi += i[S[j][q]-1]
            if ichi%2 == P[j]:
                count += 1
         j range(M) range M ichi = 0 ichi 0 for q in range(K[j]):
                ichi += i[S[j][q]-1]
             q range(K[j]) range K[j] K j ichi += i[S[j][q]-1] ichi i[S[j][q]-1] i S[j][q]-1 S[j][q] [j] S j q 1 if ichi%2 == P[j]:
                count += 1
         ichi%2 == P[j] ichi%2 ichi 2 P[j] P j count += 1 count 1 if count == M:
            ans += 1
     count == M count M ans += 1 ans 1 print(ans) print ans resolve() resolve def resolve():
    import itertools
    N, M = map(int, input().split())
    S = []
    K = []
    ans = 0
    for _ in range(M):
        s = list(map(int, input().split()))
        K.append(s[0])
        S.append(s[1:])
    P = list(map(int, input().split()))
    for i in itertools.product([0,1], repeat=N):
        count = 0
        for j in range(M):
            ichi = 0
            for q in range(K[j]):
                ichi += i[S[j][q]-1]
            if ichi%2 == P[j]:
                count += 1
        if count == M:
            ans += 1
    print(ans) def resolve():
    import itertools
    N, M = map(int, input().split())
    S = []
    K = []
    ans = 0
    for _ in range(M):
        s = list(map(int, input().split()))
        K.append(s[0])
        S.append(s[1:])
    P = list(map(int, input().split()))
    for i in itertools.product([0,1], repeat=N):
        count = 0
        for j in range(M):
            ichi = 0
            for q in range(K[j]):
                ichi += i[S[j][q]-1]
            if ichi%2 == P[j]:
                count += 1
        if count == M:
            ans += 1
    print(ans) resolve
def resolve():
    import itertools
    N, M = map(int, input().split())
    S = []
    K = []
    ans = 0
    for _ in range(M):
        s = list(map(int, input().split()))
        K.append(s[0])
        S.append(s[1:])
    P = list(map(int, input().split()))
    for i in itertools.product([0,1], repeat=N):
        count = 0
        for j in range(M):
            ichi = 0
            for q in range(K[j]):
                ichi += i[S[j][q]-1]
            if ichi%2 == P[j]:
                count += 1
        if count == M:
            ans += 1
    print(ans)
resolve()