/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
2 2
2 1 2
1 2
0 1
---+/
/+---test
2 3
2 1 2
1 1
1 2
0 0 1
---+/
/+---test
5 2
3 1 2 5
2 2 3
1 0
---+/

void main(string[] args) {
  long N, M;
  readf(" %d %d ", &N, &M);

  auto ltosw = new long[][](M);
  foreach (m; 0..M) {
    auto S = readln.split.map!(to!long).array;
    foreach (s; S[1..$]) {
      ltosw[m] ~= s-1;
    }
  }
  const P = readln.split.map!(to!long).array;

  long ans;

  const N2 = 2.pow(N);
  for (ushort i = 0; i <= N2; ++i) {
    long lcnt;
    foreach (m; 0..M) {
      long cnt;
      foreach (sw; ltosw[m]) {
        if (i >> sw & 1) ++cnt;
      }
      if (cnt%2 == P[m]) ++lcnt;
    }
    if (lcnt == M) ++ans;
  }
  ans.writeln;
}
