import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong bignum = 1_000_000_007;
alias SugarWater = Tuple!(long, "swater", long, "sugar");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, m;
    scan(n, m);
    auto lights = new long[][](m, n);
    foreach (i; iota(m))
    {
        auto k = aryread();
        foreach (s; k[1 .. $])
        {
            lights[i][s - 1]++;
        }
    }
    auto p = aryread();
    long count;
    // lights.writeln();
    foreach (i; 0 .. (1 << n))
    {
        long[] bits = i.bitary(n);
        bool check = true;
        foreach (j; iota(m))
        {
            long on;
            foreach (k; iota(n))
                on += bits[k] & lights[j][k];

            if (on % 2 != p[j])
                check = false;
        }
        if(check)
            count++;
    }
    count.writeln();
}

auto bitary(long n, long disit)
{
    auto ary = new long[](disit);
    long tmp;
    while (n > 0)
    {
        ary[tmp++] = n % 2;
        n = n >> 1;
    }
    ary.reverse();
    return ary;
}