N, M = map(int, input().split())
bulb = []
count = 0

for _ in range(M):
    tmp = list(map(int, input().split()))
    bulb.append(tmp[1:])

P = list(map(int, input().split()))

for i in range(2 ** N):
    switch = []
    for j in range(N):  # スイッチの押し方を全探索
        if (i >> j) & 1:
            switch.append(j+1)
    bulb_count = M
    for k in range(M):  # M個の電球それぞれがついているか判定
        tmp = bulb[k]  # tmpは電球k につながっているスイッチ
        switch_count = 0
        for num in tmp:  # 電球kのスイッチについて判定
            if num in switch:
                switch_count += 1
        if switch_count % 2 == P[k]:
            bulb_count -= 1
    if bulb_count == 0:
        count += 1

print(count) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M bulb = [] bulb [] count = 0 count 0 for _ in range(M):
    tmp = list(map(int, input().split()))
    bulb.append(tmp[1:]) _ range(M) range M tmp = list(map(int, input().split())) tmp list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split bulb.append(tmp[1:]) bulb.append bulb append tmp[1:] tmp 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 range(2 ** N):
    switch = []
    for j in range(N):  # スイッチの押し方を全探索
        if (i >> j) & 1:
            switch.append(j+1)
    bulb_count = M
    for k in range(M):  # M個の電球それぞれがついているか判定
        tmp = bulb[k]  # tmpは電球k につながっているスイッチ
        switch_count = 0
        for num in tmp:  # 電球kのスイッチについて判定
            if num in switch:
                switch_count += 1
        if switch_count % 2 == P[k]:
            bulb_count -= 1
    if bulb_count == 0:
        count += 1 i range(2 ** N) range 2 ** N 2 N switch = [] switch [] for j in range(N):  # スイッチの押し方を全探索
        if (i >> j) & 1:
            switch.append(j+1)
     j range(N) range N if (i >> j) & 1:
            switch.append(j+1)
     (i >> j) & 1 i >> j i j 1 switch.append(j+1) switch.append switch append j+1 j 1 bulb_count = M bulb_count M for k in range(M):  # M個の電球それぞれがついているか判定
        tmp = bulb[k]  # tmpは電球k につながっているスイッチ
        switch_count = 0
        for num in tmp:  # 電球kのスイッチについて判定
            if num in switch:
                switch_count += 1
        if switch_count % 2 == P[k]:
            bulb_count -= 1
     k range(M) range M tmp = bulb[k] tmp bulb[k] bulb k switch_count = 0 switch_count 0 for num in tmp:  # 電球kのスイッチについて判定
            if num in switch:
                switch_count += 1
         num tmp if num in switch:
                switch_count += 1
         num in switch num switch switch_count += 1 switch_count 1 if switch_count % 2 == P[k]:
            bulb_count -= 1
     switch_count % 2 == P[k] switch_count % 2 switch_count 2 P[k] P k bulb_count -= 1 bulb_count 1 if bulb_count == 0:
        count += 1 bulb_count == 0 bulb_count 0 count += 1 count 1 print(count) print count bulb = [] [] bulb bulb_count -= 1 1 bulb_count switch_count += 1 1 switch_count switch = [] [] switch tmp = bulb[k] bulb[k] tmp P = list(map(int, input().split())) list(map(int, input().split())) P switch_count = 0 0 switch_count N, M = map(int, input().split()) map(int, input().split()) N count = 0 0 count M = map(int, input().split()) map(int, input().split()) M tmp = list(map(int, input().split())) list(map(int, input().split())) tmp count += 1 1 count bulb_count = M M bulb_count
N, M = map(int, input().split())
bulb = []
count = 0

for _ in range(M):
    tmp = list(map(int, input().split()))
    bulb.append(tmp[1:])

P = list(map(int, input().split()))

for i in range(2 ** N):
    switch = []
    for j in range(N):  # スイッチの押し方を全探索
        if (i >> j) & 1:
            switch.append(j+1)
    bulb_count = M
    for k in range(M):  # M個の電球それぞれがついているか判定
        tmp = bulb[k]  # tmpは電球k につながっているスイッチ
        switch_count = 0
        for num in tmp:  # 電球kのスイッチについて判定
            if num in switch:
                switch_count += 1
        if switch_count % 2 == P[k]:
            bulb_count -= 1
    if bulb_count == 0:
        count += 1

print(count)
