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

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n, m; scan(n, m);

    int[][] ms;
    for (int i = 0; i < m; i++) {
        auto ss = readints;
        ms ~= ss[1..$].map!(e => e - 1).array;
    }
    auto ps = readints;

    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {
        auto state = new bool[n];
        for (int j = 0; j < n; j++) {
            if (i & (1 << j)) state[j] = true;
        }

        bool ok = true;
        for (int j = 0; j < m; j++) {
            int p = 0;
            foreach (k; ms[j]) {
                if (state[k]) p++;
            }
            if (p % 2 != ps[j]) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    }
    writeln(ans);
}
