#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s[50][50], p[50], res = 0;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    cin >> s[i][0];
    for (int j = 1; j <= s[i][0]; ++j) cin >> s[i][j];
  }
  for (int i = 1; i <= m; ++i) cin >> p[i];
  for (int i = 0; i < (1 << n); ++i) {
    int step = 0;
    bool ok = 1;
    for (int j = 1; ok && j <= m; ++j) {
      int nr = 0;
      for (int k = 1; ok && k <= s[j][0]; ++k)
        if (i & (1 << s[j][k])) ++nr;
      if (nr % 2 == p[j])
        ok = 0;
      else
        ++step;
    }
    if (step == m) ++res;
  }
  cout << res;
  return 0;
}
