import std.stdio, std.string, std.conv;

void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], m = tmp[1];
    int[][] s = new int[][](m);
    foreach (i; 0 .. m) {
        int[] ss = readln.split.to!(int[]);
        ss = ss[1..$];
        foreach (x; ss) {
            s[i] ~= x - 1;
        }
    }
    int[] p = readln.split.to!(int[]);
    int ans;
    for (int i = 0; i < (1 << n); ++i) {
        bool ok;
        foreach (j; 0 .. m) {
            int cnt;
            foreach (x; s[j]) {
                if ((i >> x) & 1) ++cnt;
            }
            cnt %= 2;
            if (cnt != p[j]) ok = true;
        }
        if (!ok) ++ans;
    }
    ans.writeln;
}