def resolve():
    N, M = list(map(int, input().split()))
    swi = []
    for i in range(M):
        k, *ss = list(map(int, input().split()))
        t = 0
        for s in ss:
            t += 1 << (s-1)
        swi.append(t)

    ps = list(map(int, input().split()))
    ans = 0
    for i in range(1 << N):
        for s, p in zip(swi, ps):
            t = i & s
            c = bin(t).count('1') % 2
            if c != p:
                break
        else:
            ans += 1
    print(ans)
    return

resolve() def resolve():
    N, M = list(map(int, input().split()))
    swi = []
    for i in range(M):
        k, *ss = list(map(int, input().split()))
        t = 0
        for s in ss:
            t += 1 << (s-1)
        swi.append(t)

    ps = list(map(int, input().split()))
    ans = 0
    for i in range(1 << N):
        for s, p in zip(swi, ps):
            t = i & s
            c = bin(t).count('1') % 2
            if c != p:
                break
        else:
            ans += 1
    print(ans)
    return resolve N, M = list(map(int, input().split())) N list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split M swi = [] swi [] for i in range(M):
        k, *ss = list(map(int, input().split()))
        t = 0
        for s in ss:
            t += 1 << (s-1)
        swi.append(t)

     i range(M) range M k, *ss = list(map(int, input().split())) k list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split *ss ss t = 0 t 0 for s in ss:
            t += 1 << (s-1)
         s ss t += 1 << (s-1) t 1 << (s-1) 1 s-1 s 1 swi.append(t) swi.append swi append t ps = list(map(int, input().split())) ps 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):
        for s, p in zip(swi, ps):
            t = i & s
            c = bin(t).count('1') % 2
            if c != p:
                break
        else:
            ans += 1
     i range(1 << N) range 1 << N 1 N for s, p in zip(swi, ps):
            t = i & s
            c = bin(t).count('1') % 2
            if c != p:
                break
        else:
            ans += 1
     s p zip(swi, ps) zip swi ps t = i & s t i & s i s c = bin(t).count('1') % 2 c bin(t).count('1') % 2 bin(t).count('1') (t).count (t) bin t count '1' 2 if c != p:
                break
         c != p c p break ans += 1 ans 1 print(ans) print ans return resolve() resolve def resolve():
    N, M = list(map(int, input().split()))
    swi = []
    for i in range(M):
        k, *ss = list(map(int, input().split()))
        t = 0
        for s in ss:
            t += 1 << (s-1)
        swi.append(t)

    ps = list(map(int, input().split()))
    ans = 0
    for i in range(1 << N):
        for s, p in zip(swi, ps):
            t = i & s
            c = bin(t).count('1') % 2
            if c != p:
                break
        else:
            ans += 1
    print(ans)
    return def resolve():
    N, M = list(map(int, input().split()))
    swi = []
    for i in range(M):
        k, *ss = list(map(int, input().split()))
        t = 0
        for s in ss:
            t += 1 << (s-1)
        swi.append(t)

    ps = list(map(int, input().split()))
    ans = 0
    for i in range(1 << N):
        for s, p in zip(swi, ps):
            t = i & s
            c = bin(t).count('1') % 2
            if c != p:
                break
        else:
            ans += 1
    print(ans)
    return resolve
def resolve():
    N, M = list(map(int, input().split()))
    swi = []
    for i in range(M):
        k, *ss = list(map(int, input().split()))
        t = 0
        for s in ss:
            t += 1 << (s-1)
        swi.append(t)

    ps = list(map(int, input().split()))
    ans = 0
    for i in range(1 << N):
        for s, p in zip(swi, ps):
            t = i & s
            c = bin(t).count('1') % 2
            if c != p:
                break
        else:
            ans += 1
    print(ans)
    return

resolve()