import std.stdio, std.string, std.conv, std.array, std.range, std.algorithm, std.typecons;

void main() {
    long n, m;
    readf("%d %d\n", &n, &m);

    long[][] ss = [];
    foreach (i; 0..m) {
        ss ~= readln.strip.split(" ")[1..$].map!(to!long).array;
    }
    long[] ps = readln.strip.split(" ").map!(to!long).array;

    long solve(long k, long[] sw) {
        if (k >= n) {
            long ret = 0;
            foreach (i; 0..m) {
                long cnt = 0;
                foreach (j; 0..n) {
                    if (ss[i].canFind(j+1)) {
                        cnt += sw[j];
                    }
                }
                if (cnt % 2 == ps[i]) {
                    ret++;
                }
            }
            if (ret == m) {
                return 1;
            }
            return 0;
        }

        long a = solve(k+1, sw);
        long[] sw2 = sw.dup;
        sw2[k] = 1;
        long b = solve(k+1, sw2);
        return a+ b;
    }

    long ans = solve(0, new long[](n));
    writeln(ans);
}
