import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto A = M.iota.map!(_ => readln.split.map!(to!int).array).array;
    auto P = readln.split.map!(to!int).array;

    int ans = 0;

    foreach (mask; 0..(1<<N)) {
        bool ok = true;
        foreach (i; 0..M) {
            int p = 0;
            foreach (j; 1..A[i].length.to!int) {
                int x = A[i][j] - 1;
                if (mask & (1 << x)) {
                    p ^= 1;
                }
            }
            if (p != P[i]) {
                ok = false;
                break;
            }
        }
        ans += ok;
    }

    ans.writeln;
}