#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ifstream inputFile("data/input.txt");
  if (getenv("SSH_CONNECTION") != nullptr) {
    cin.rdbuf(inputFile.rdbuf());
  }
  int N, M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> s(M, vector<int>(N, 0));
  vector<int> p(M);
  for (int i = 0; (i < M); ++i) {
    cin >> k[i];
    for (int j = 0; (j < k[i]); ++j) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; (i < M); ++i) {
    cin >> p[i];
  }
  int res = 0;
  for (int i = 0; (i < pow(2, N)); ++i) {
    int numOn = 0;
    for (int j = 0; (j < M); ++j) {
      int sum = 0;
      for (int kk = 0; (kk < k[j]); ++kk) {
        sum += (i >> kk) & 0x1;
      }
      if (p[j] == sum % 2) ++numOn;
    }
    if (numOn == M) ++res;
  }
  cout << res << endl;
  return 0;
}
