#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846;
long long s[10][10];
long long p[10];
long long N, M;
long long k;
long long c;
bool judge(string second) {
  for (long long den = 0; den < M; den++) {
    long long cOn = 0;
    for (long long swi = 0; swi < 10; swi++) {
      long long kswitch = s[den][swi];
      if (kswitch == 0) break;
      if (second[kswitch] == '1') {
        cOn++;
      }
    }
    if (cOn == 0) {
      return false;
    }
    if (cOn % 2 != p[den]) {
      cerr << " -> off" << endl;
      return false;
    }
  }
  cerr << " -> on" << endl;
  return true;
}
void dfs(long long i, string second) {
  if (N <= i) {
    if (judge(second)) {
      c++;
    }
    return;
  }
  dfs(i + 1, second + "0");
  dfs(i + 1, second + "1");
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  for (long long i = 0; i < M; i++) {
    cin >> k;
    for (long long j = 0; j < k; j++) {
      cin >> s[i][j];
    }
  }
  for (long long i = 0; i < M; i++) {
    cin >> p[i];
  }
  dfs(0, "-");
  cout << c << endl;
  return 0;
}
