import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import product
def main():
    n, m = map(int, input().split())
    light_bulbs = {i: [] for i in range(m)}
    for i0 in range(m):
        data = tuple(map(int, input().split()))
        light_bulbs[i0]= data[1:]
    p = tuple(map(int, input().split()))

    pat = tuple(product((0, 1), repeat=n))
    res = 0
    for pate in pat:
        light_on = 0
        for i, bulb in enumerate(light_bulbs.values()):
            turned_switch = 0
            for bulb_switch in bulb:
                turned_switch += pate[bulb_switch - 1]
            if turned_switch % 2 == p[i]:
                light_on += 1
        if light_on == m:
            res += 1
    print(res)

if __name__ == '__main__':
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines from itertools import product def main():
    n, m = map(int, input().split())
    light_bulbs = {i: [] for i in range(m)}
    for i0 in range(m):
        data = tuple(map(int, input().split()))
        light_bulbs[i0]= data[1:]
    p = tuple(map(int, input().split()))

    pat = tuple(product((0, 1), repeat=n))
    res = 0
    for pate in pat:
        light_on = 0
        for i, bulb in enumerate(light_bulbs.values()):
            turned_switch = 0
            for bulb_switch in bulb:
                turned_switch += pate[bulb_switch - 1]
            if turned_switch % 2 == p[i]:
                light_on += 1
        if light_on == m:
            res += 1
    print(res) main n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m i: [] for i in range(m) for i in range(m) i range(m) range m for i in range(m) i [] light_bulbs = {i: [] for i in range(m)} light_bulbs {i: [] for i in range(m)} for i0 in range(m):
        data = tuple(map(int, input().split()))
        light_bulbs[i0]= data[1:]
     i0 range(m) range m data = tuple(map(int, input().split())) data tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split light_bulbs[i0]= data[1:] light_bulbs[i0] light_bulbs i0 data[1:] data 1: 1 p = tuple(map(int, input().split())) p tuple(map(int, input().split())) tuple map(int, input().split()) map int input().split() ().split () input split pat = tuple(product((0, 1), repeat=n)) pat tuple(product((0, 1), repeat=n)) tuple product((0, 1), repeat=n) product (0, 1) 0 1 repeat=n repeat n res = 0 res 0 for pate in pat:
        light_on = 0
        for i, bulb in enumerate(light_bulbs.values()):
            turned_switch = 0
            for bulb_switch in bulb:
                turned_switch += pate[bulb_switch - 1]
            if turned_switch % 2 == p[i]:
                light_on += 1
        if light_on == m:
            res += 1
     pate pat light_on = 0 light_on 0 for i, bulb in enumerate(light_bulbs.values()):
            turned_switch = 0
            for bulb_switch in bulb:
                turned_switch += pate[bulb_switch - 1]
            if turned_switch % 2 == p[i]:
                light_on += 1
         i bulb enumerate(light_bulbs.values()) enumerate light_bulbs.values() light_bulbs.values light_bulbs values turned_switch = 0 turned_switch 0 for bulb_switch in bulb:
                turned_switch += pate[bulb_switch - 1]
             bulb_switch bulb turned_switch += pate[bulb_switch - 1] turned_switch pate[bulb_switch - 1] pate bulb_switch - 1 bulb_switch 1 if turned_switch % 2 == p[i]:
                light_on += 1
         turned_switch % 2 == p[i] turned_switch % 2 turned_switch 2 p[i] p i light_on += 1 light_on 1 if light_on == m:
            res += 1
     light_on == m light_on m res += 1 res 1 print(res) print res if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main read = sys.stdin.read sys.stdin.read read readlines = sys.stdin.readlines sys.stdin.readlines readlines def main():
    n, m = map(int, input().split())
    light_bulbs = {i: [] for i in range(m)}
    for i0 in range(m):
        data = tuple(map(int, input().split()))
        light_bulbs[i0]= data[1:]
    p = tuple(map(int, input().split()))

    pat = tuple(product((0, 1), repeat=n))
    res = 0
    for pate in pat:
        light_on = 0
        for i, bulb in enumerate(light_bulbs.values()):
            turned_switch = 0
            for bulb_switch in bulb:
                turned_switch += pate[bulb_switch - 1]
            if turned_switch % 2 == p[i]:
                light_on += 1
        if light_on == m:
            res += 1
    print(res) def main():
    n, m = map(int, input().split())
    light_bulbs = {i: [] for i in range(m)}
    for i0 in range(m):
        data = tuple(map(int, input().split()))
        light_bulbs[i0]= data[1:]
    p = tuple(map(int, input().split()))

    pat = tuple(product((0, 1), repeat=n))
    res = 0
    for pate in pat:
        light_on = 0
        for i, bulb in enumerate(light_bulbs.values()):
            turned_switch = 0
            for bulb_switch in bulb:
                turned_switch += pate[bulb_switch - 1]
            if turned_switch % 2 == p[i]:
                light_on += 1
        if light_on == m:
            res += 1
    print(res) main
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import product
def main():
    n, m = map(int, input().split())
    light_bulbs = {i: [] for i in range(m)}
    for i0 in range(m):
        data = tuple(map(int, input().split()))
        light_bulbs[i0]= data[1:]
    p = tuple(map(int, input().split()))

    pat = tuple(product((0, 1), repeat=n))
    res = 0
    for pate in pat:
        light_on = 0
        for i, bulb in enumerate(light_bulbs.values()):
            turned_switch = 0
            for bulb_switch in bulb:
                turned_switch += pate[bulb_switch - 1]
            if turned_switch % 2 == p[i]:
                light_on += 1
        if light_on == m:
            res += 1
    print(res)

if __name__ == '__main__':
    main()