# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


n, m = map(int, input().split())
arr = []
for _ in range(m):
    tmp = list(map(int, input().split()))
    arr.append(tmp[1:])
prr = list(map(int, input().split()))

answer = 0
for switches in range(2 ** n):
    light_up = 0
    for light in range(m):
        on = 0
        for shift in range(n):
            if (switches >> shift) & 1 and (shift + 1) in arr[light]:
                on += 1

        if on % 2 == prr[light]:
            light_up += 1

    if light_up == m:
        answer += 1

print(answer) def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums calc_digit_sum digits = sums = 0 digits 0 = sums = 0 sums 0 while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
     num > 0 num 0 digits += 1 digits 1 sums += num % 10 sums num % 10 num 10 num //= 10 num 10 return digits, sums return digits, sums digits sums num num n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m arr = [] arr [] for _ in range(m):
    tmp = list(map(int, input().split()))
    arr.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 arr.append(tmp[1:]) arr.append arr append tmp[1:] tmp 1: 1 prr = list(map(int, input().split())) prr list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split answer = 0 answer 0 for switches in range(2 ** n):
    light_up = 0
    for light in range(m):
        on = 0
        for shift in range(n):
            if (switches >> shift) & 1 and (shift + 1) in arr[light]:
                on += 1

        if on % 2 == prr[light]:
            light_up += 1

    if light_up == m:
        answer += 1 switches range(2 ** n) range 2 ** n 2 n light_up = 0 light_up 0 for light in range(m):
        on = 0
        for shift in range(n):
            if (switches >> shift) & 1 and (shift + 1) in arr[light]:
                on += 1

        if on % 2 == prr[light]:
            light_up += 1

     light range(m) range m on = 0 on 0 for shift in range(n):
            if (switches >> shift) & 1 and (shift + 1) in arr[light]:
                on += 1

         shift range(n) range n if (switches >> shift) & 1 and (shift + 1) in arr[light]:
                on += 1

         (switches >> shift) & 1 and (shift + 1) in arr[light] (switches >> shift) & 1 switches >> shift switches shift 1 (shift + 1) in arr[light] shift + 1 shift 1 arr[light] arr light on += 1 on 1 if on % 2 == prr[light]:
            light_up += 1

     on % 2 == prr[light] on % 2 on 2 prr[light] prr light light_up += 1 light_up 1 if light_up == m:
        answer += 1 light_up == m light_up m answer += 1 answer 1 print(answer) print answer m = map(int, input().split()) map(int, input().split()) m tmp = list(map(int, input().split())) list(map(int, input().split())) tmp answer += 1 1 answer arr = [] [] arr answer = 0 0 answer n, m = map(int, input().split()) map(int, input().split()) n on = 0 0 on light_up += 1 1 light_up on += 1 1 on def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums calc_digit_sum light_up = 0 0 light_up prr = list(map(int, input().split())) list(map(int, input().split())) prr
# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


n, m = map(int, input().split())
arr = []
for _ in range(m):
    tmp = list(map(int, input().split()))
    arr.append(tmp[1:])
prr = list(map(int, input().split()))

answer = 0
for switches in range(2 ** n):
    light_up = 0
    for light in range(m):
        on = 0
        for shift in range(n):
            if (switches >> shift) & 1 and (shift + 1) in arr[light]:
                on += 1

        if on % 2 == prr[light]:
            light_up += 1

    if light_up == m:
        answer += 1

print(answer)