n , m = map(int, input().split())

switch = []
for i in range(m):
    line = list(map(int, input().split()))
    k, s = line[0], line[1::]
    switch.append(s)

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

# print("######################################")
res = 0
for i in range(1 << n):
    on_off_state = []
    for index in range(n):
        if i >> index & 1 == 1:
            on_off_state.append("on")
        else:
            on_off_state.append("off")
    for ki in range(m):
        on_off_counter = 0
        for i_switch in switch[ki]:
            if on_off_state[i_switch - 1] == "on":
                on_off_counter += 1
        if on_off_counter % 2 != is_on_off[ki]:
            break
    else:
        res += 1
    # print(res, i)

print(res)
 n , m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m switch = [] switch [] for i in range(m):
    line = list(map(int, input().split()))
    k, s = line[0], line[1::]
    switch.append(s) i range(m) range m line = list(map(int, input().split())) line list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k, s = line[0], line[1::] k line[0] line 0 s line[1::] line 1:: 1 switch.append(s) switch.append switch append s is_on_off = list(map(int, input().split())) is_on_off list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split res = 0 res 0 for i in range(1 << n):
    on_off_state = []
    for index in range(n):
        if i >> index & 1 == 1:
            on_off_state.append("on")
        else:
            on_off_state.append("off")
    for ki in range(m):
        on_off_counter = 0
        for i_switch in switch[ki]:
            if on_off_state[i_switch - 1] == "on":
                on_off_counter += 1
        if on_off_counter % 2 != is_on_off[ki]:
            break
    else:
        res += 1
    # print(res, i) i range(1 << n) range 1 << n 1 n on_off_state = [] on_off_state [] for index in range(n):
        if i >> index & 1 == 1:
            on_off_state.append("on")
        else:
            on_off_state.append("off")
     index range(n) range n if i >> index & 1 == 1:
            on_off_state.append("on")
        else:
            on_off_state.append("off")
     i >> index & 1 == 1 i >> index & 1 i >> index i index 1 1 on_off_state.append("on") on_off_state.append on_off_state append "on" on_off_state.append("off") on_off_state.append on_off_state append "off" for ki in range(m):
        on_off_counter = 0
        for i_switch in switch[ki]:
            if on_off_state[i_switch - 1] == "on":
                on_off_counter += 1
        if on_off_counter % 2 != is_on_off[ki]:
            break
    else:
        res += 1
    # print(res, i) ki range(m) range m on_off_counter = 0 on_off_counter 0 for i_switch in switch[ki]:
            if on_off_state[i_switch - 1] == "on":
                on_off_counter += 1
         i_switch switch[ki] switch ki if on_off_state[i_switch - 1] == "on":
                on_off_counter += 1
         on_off_state[i_switch - 1] == "on" on_off_state[i_switch - 1] on_off_state i_switch - 1 i_switch 1 "on" on_off_counter += 1 on_off_counter 1 if on_off_counter % 2 != is_on_off[ki]:
            break
     on_off_counter % 2 != is_on_off[ki] on_off_counter % 2 on_off_counter 2 is_on_off[ki] is_on_off ki break res += 1 res 1 print(res) print res switch = [] [] switch s = line[0], line[1::] line[1::] s line = list(map(int, input().split())) list(map(int, input().split())) line k, s = line[0], line[1::] line[0] k n , m = map(int, input().split()) map(int, input().split()) n is_on_off = list(map(int, input().split())) list(map(int, input().split())) is_on_off res = 0 0 res res += 1 1 res on_off_counter = 0 0 on_off_counter on_off_counter += 1 1 on_off_counter m = map(int, input().split()) map(int, input().split()) m on_off_state = [] [] on_off_state
n , m = map(int, input().split())

switch = []
for i in range(m):
    line = list(map(int, input().split()))
    k, s = line[0], line[1::]
    switch.append(s)

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

# print("######################################")
res = 0
for i in range(1 << n):
    on_off_state = []
    for index in range(n):
        if i >> index & 1 == 1:
            on_off_state.append("on")
        else:
            on_off_state.append("off")
    for ki in range(m):
        on_off_counter = 0
        for i_switch in switch[ki]:
            if on_off_state[i_switch - 1] == "on":
                on_off_counter += 1
        if on_off_counter % 2 != is_on_off[ki]:
            break
    else:
        res += 1
    # print(res, i)

print(res)

