N, M = map(int, input().split())
switches_bulbs_connection = {}

for i in range(M):
    switches_bulbs_connection[i] = list(map(int, input().split()))[1:]
p = list(map(int, input().split()))
count = 0
flag = 0

for i in range(2 ** N):  # スイッチのon/offについてビット全探索
    switch_on_off = [0] * N
    bulb_stat = [0] * M
    for j in range(N):
        if (i >> j) & 1:
            switch_on_off[j] += 1  # 各スイッチがonかoffか
    for k in range(M):  # 電球kについて調べる
        tmp = switches_bulbs_connection[k]
        for switch in tmp:
            if switch_on_off[switch-1]:
                bulb_stat[k] += 1
    for l in range(M):
        if bulb_stat[l] % 2 == p[l]:
            flag += 1
    if flag == M:
        count += 1
    flag = 0

print(count) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M switches_bulbs_connection = {} switches_bulbs_connection {} for i in range(M):
    switches_bulbs_connection[i] = list(map(int, input().split()))[1:] i range(M) range M switches_bulbs_connection[i] = list(map(int, input().split()))[1:] switches_bulbs_connection[i] switches_bulbs_connection i list(map(int, input().split()))[1:] (map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split 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 count = 0 count 0 flag = 0 flag 0 for i in range(2 ** N):  # スイッチのon/offについてビット全探索
    switch_on_off = [0] * N
    bulb_stat = [0] * M
    for j in range(N):
        if (i >> j) & 1:
            switch_on_off[j] += 1  # 各スイッチがonかoffか
    for k in range(M):  # 電球kについて調べる
        tmp = switches_bulbs_connection[k]
        for switch in tmp:
            if switch_on_off[switch-1]:
                bulb_stat[k] += 1
    for l in range(M):
        if bulb_stat[l] % 2 == p[l]:
            flag += 1
    if flag == M:
        count += 1
    flag = 0 i range(2 ** N) range 2 ** N 2 N switch_on_off = [0] * N switch_on_off [0] * N [0] 0 N bulb_stat = [0] * M bulb_stat [0] * M [0] 0 M for j in range(N):
        if (i >> j) & 1:
            switch_on_off[j] += 1  # 各スイッチがonかoffか
     j range(N) range N if (i >> j) & 1:
            switch_on_off[j] += 1  # 各スイッチがonかoffか
     (i >> j) & 1 i >> j i j 1 switch_on_off[j] += 1 switch_on_off[j] switch_on_off j 1 for k in range(M):  # 電球kについて調べる
        tmp = switches_bulbs_connection[k]
        for switch in tmp:
            if switch_on_off[switch-1]:
                bulb_stat[k] += 1
     k range(M) range M tmp = switches_bulbs_connection[k] tmp switches_bulbs_connection[k] switches_bulbs_connection k for switch in tmp:
            if switch_on_off[switch-1]:
                bulb_stat[k] += 1
     switch tmp if switch_on_off[switch-1]:
                bulb_stat[k] += 1
     switch_on_off[switch-1] switch_on_off switch-1 switch 1 bulb_stat[k] += 1 bulb_stat[k] bulb_stat k 1 for l in range(M):
        if bulb_stat[l] % 2 == p[l]:
            flag += 1
     l range(M) range M if bulb_stat[l] % 2 == p[l]:
            flag += 1
     bulb_stat[l] % 2 == p[l] bulb_stat[l] % 2 bulb_stat[l] bulb_stat l 2 p[l] p l flag += 1 flag 1 if flag == M:
        count += 1
     flag == M flag M count += 1 count 1 flag = 0 flag 0 print(count) print count M = map(int, input().split()) map(int, input().split()) M count += 1 1 count switches_bulbs_connection = {} {} switches_bulbs_connection flag = 0 0 flag switch_on_off = [0] * N [0] * N switch_on_off p = list(map(int, input().split())) list(map(int, input().split())) p count = 0 0 count bulb_stat = [0] * M [0] * M bulb_stat N, M = map(int, input().split()) map(int, input().split()) N flag += 1 1 flag tmp = switches_bulbs_connection[k] switches_bulbs_connection[k] tmp flag = 0 0 flag
N, M = map(int, input().split())
switches_bulbs_connection = {}

for i in range(M):
    switches_bulbs_connection[i] = list(map(int, input().split()))[1:]
p = list(map(int, input().split()))
count = 0
flag = 0

for i in range(2 ** N):  # スイッチのon/offについてビット全探索
    switch_on_off = [0] * N
    bulb_stat = [0] * M
    for j in range(N):
        if (i >> j) & 1:
            switch_on_off[j] += 1  # 各スイッチがonかoffか
    for k in range(M):  # 電球kについて調べる
        tmp = switches_bulbs_connection[k]
        for switch in tmp:
            if switch_on_off[switch-1]:
                bulb_stat[k] += 1
    for l in range(M):
        if bulb_stat[l] % 2 == p[l]:
            flag += 1
    if flag == M:
        count += 1
    flag = 0

print(count)
