#include <bits/stdc++.h>
using namespace std;
constexpr long long int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n - 1); }
vector<int> B[20];
vector<int> P;
int main(void) {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int b;
      cin >> b;
      B[i].push_back(b);
    }
  }
  for (int i = 0; i < M; i++) {
    int p;
    cin >> p;
    P.push_back(p);
  }
  int ans = 0;
  for (int i = 1; i < (1 << N); i++) {
    bool flag = true;
    for (int m = 0; m < N; m++) {
      int count = 0;
      for (int j = 0; j < B[m].size(); j++) {
        if ((i & 1 << (B[m][j] - 1))) {
          count++;
        }
      }
      if (count % 2 != P[m]) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
